Typically, the best policy is to make your future plans (move, new job, whatever) and get everything finalized, then tell your employer. In other words, wait until you have your living situation and your job in your new city all taken care of - in writing. The limiting factor on this in the very short term is ensuring you respect the notice period in your contract, if there is one, or the cultural/industry norms. For instance, in my culture and industry, it's typical to give 2 weeks notice.
The danger in letting your employer know any earlier than that is, they may "write you off" as expendable. If you are planning a move to another city, and a new job, it may take a while before everything clicks and you find a new job, etc. If you tell your employer ahead of time, and they decide to replace you immediately (on their timeline, instead of yours) - you could be put in a very bad spot if your plans change - you have trouble finding a new job, your lease on your new apartment gets pushed back, whatever.
If you already have a new job (in writing - a contract or signed offer letter), you know where you're going to live, and all the details are final, and you don't mind the chance that you'll become unemployed at some point in the next year - you can go ahead and tell your employer. Otherwise, wait until your typical notice period.