In A Time for War, A Time for Peace:
Worf decided after various events had occurred, that he was not of the right temperament to be the Federation ambassador and although the new Federation president disagreed, she accepted his resignation. Worf then nominated his son Alexander, to be his replacement as ambassador. Worf decided that after serving the Klingon Empire and the Federation and always doing what was expected of him that the time had come for him to be selfish and he wanted to go back to Starfleet, where he felt the most fulfilled. Admiral Ross immediately reinstated his rank of lt. commander and assigned him to be first officer on the Titan under Captain Riker. Worf was filling in at the tactical station during the events of Star Trek Nemesis as the Enterprise's chief of security, Christine Vale, had taken shore leave on Earth and the second in command of security had recently resigned.
I don't believe there was an explanation in the show as to why he changed the job. Oddly enough, in Star Trek Online, "Worf has remained ambassador to Qo'noS and remains one of the few pro-Federation voices in the Empire after the breakdown of the Khitomer Accords," which suggests events there operated differently.