What I should write to a professor to decline a PhD offer, while I have accepted it months ago?
I would suggest writing something like this:


  For personal reasons, it turns out that I cannot attend this university after all; I will be moving overseas. I am sorry I will not be able to work with you. Thank you very much for your time. I apologize for the inconvenience and late notice.


It is possible that he may be a little disappointed or annoyed, or  suspect that you  are moving because you have another offer that you prefer for academic reasons, but I don't think it should be a huge deal. You've exchanged some emails, but it isn't as if he has invested years of his time in working with you. It's generally not a good idea to go around alienating people in the small world of  academia, but I don't think one slightly annoyed professor will cause any real harm to your career. Anyway, clearly this decision is important enough to you that it's worth the risk.

It's possible he would be more understanding if he knew the real reason. It's your decision to whom you want to come out, and I can't offer any advice on that. But you should only tell him if you're really comfortable with doing so; I don't think the academic consequences of keeping it private are significant enough to enter in the decision.

The phrase "personal reasons" is intended as a polite signal that you don't intend to discuss those reasons, and that it would be rude for him to press you. There is some cultural context there (I am in the US) so it's of course possible he won't take it that way. If you know a better way to express this to him, by all means use it.  If he is rude enough to demand more information than you want to share, you can just repeat that "it is a personal matter".