Your Bosses are Human Too
It is unlikely that any reasonable person will fault you for moving away for family reasons. This is a nice clean split, with a clear reason, with advance notice, and that should be good for all parties. Don't assume you are doing something wrong -- you aren't. Life gets in the way sometimes, and there isn't much you (or your bosses) can do about it.
How to Bring it Up
If you get along well with one of your managers, and you trust him/her (e.g. he/she is a decent human being), just schedule a meeting and explain the situation like you did in this post.
Hey boss, my significant other just got a great job opportunity in a different city. I don't want to leave this company yet, but I also owe it to my significant other to let them take advantage of this opportunity. That job starts in 5-6 months, and we will be moving, so my last day would be around X. What can I do to make this transition easier for the company?
Handling the transition is your boss' responsibility -- not yours. And giving him/her more time to do it will make it easier for them. So just be honest. Remember -- you're not doing anything wrong. I'd even take it a step further, and add in something like:
Since I just found out, I haven't really figured out what I will be doing for work once I get there. I would really appreciate it if you would be a reference for me. If you have any contacts in that city, I would really appreciate any support you can give.
If you don't trust your manager as a human being and/or are worried that they may shove you in a corner to pay for your sins for the next 5-6 months before you leave, then don't share that info until the minimum notice time. But realize it will leave a bad taste in everyone's mouth. You want to keep these people as references, so hopefully you can trust them to act like non-spiteful folk.