My paper has been accepted after several rounds of revisions. The editor him-/herself gave quite detailed comments some of which were quite important. Should I thank him/her personally for the acceptance of the paper and/or his effort(s) (the latter I have done before in my replies to reviews).
I don't see anyone reason why you shouldn't. Although, don't thank them for accepting the paper. A good editor will accept an article by someone they dislike or they wholeheartedly disagree with but which makes a good argument. It's their job. It's not a favor to you personally.
In addition, you can mention it where you acknowledge everybody else who contributed with their comments. It's not uncommon to see papers whose authors thank editors or (anonymous) reviewers for their comments if they went beyond what is ordinarily expected of them. This seems to be the case here.
It is proper etiquette, and accepted code of conduct in mathematical circles, to thank anyone who had contributed to your paper in a non-trivial manner. Hence, if the editor has made useful comments that improve your paper in some way, you could add a thank-you note to this effect in the final version. Something like "I thank the editor for useful suggestions/comments"