Comment It All Depends... (Score 1) 333
It all depends on your relationship with your manager and your trust/feel/vibe for your employer.
If you have a positive relationship and trust 3-6 months is a fairly safe window that minimizes your risks. If you are unusual you might talk about it a year or more out (I've had these discussions especially in the context of performance and development). If you are in a role where you have an individualized employment contract you might also have specific language and terms there.
If you are unsure you just wait. The challenge is firing you after discussing retirement is potentially retaliation but fighting especially at retirement time is hard. Damages are limited as your "future wages" are small. Also watch out if you are covered by binding arbitration causes - arbitrators have shameful record of siding with employers way more than the courts and even when they find for the employee providing smaller awards when they do.
Consider financial factors on timing. On the delay side like any departure also watch out for big large period (quarterly/annual) payouts - bonuses, stock vesting, 401k match, etc. If in doubt wait until your next chunk due before retirement is in the bank. What is the financial health of the company? Are there layoffs coming? Could you potentially pick up a "package" on the way out? Is there a sabbatical or other long period benefit you want to receive before you go?
On the accelerate side do you have a lot of accrued PTO/vacation to be paid out that is potentially at risk? Do you normally carry a large "float" of expenses on personal cards/$$?
Consider talking to a lawyer (and tax planner if you haven't). You may have employment agreements that cover you into retirement that may impact you especially if you plan to work on the side. Also an employment law lawyer can advise you on exactly how to bring up the topic without giving "constructive notice" (effectively the employer constitutes your inquiry as an official notice of termination of employment).
In the end - be careful and put yourself first. Many a person has had last minute retirement plans change due to unexpected shifts in financial circumstance. In a healthy organization you should be able to have this conversation well in advance - but unfortunately the window of places this type of constructive 2-way dialog is possible is shrinking. On the other hand if your skill is critical and amenable to remote and part time work you might also work out a mutually beneficial arrangement for some post-retirement income as consulting. Do you have friends or family you might refer in later (not for bonus but just for the mutual benefit of the friend and family plus company)?
In the end you will have to make a choice on risk of early notice and associated early termination against the desire to do the right thing and keep a good relationship with your former employer and co-workers.