I would say announcing it around mid to late season and making it effective at the end of the season.
My thoughts are to make the retirement less of the season focalpoint if announced too early. Announced mid to late season allows the team to get used to the thought, maybe play a bit harder for you (win one for the gipper) and allow the players and league time to properly retire you. You may not want any celebrating, but is important to your boys to have you go out properly.
Effectively retiring at the end of the season allows any future head coach a full off season to organize and a fresh start next year.