Well, yes and no. It's tricky to fit in, because it's supposed to be something the Doctor did during an unseen adventure, but all the previous Tom Baker serials pretty much flowed directly into each other without a lot of room to insert stories in between them. It would've made more sense if the face of Xoanon had been of an earlier Doctor, but then we wouldn't have had the Sevateem recognizing the Doctor as the evil one.
Terrance Dicks's novelization of "The Face of Evil" explained that it had happened during "Robot" -- one night during the story, the Doctor had slipped out to the TARDIS, taken a quick trip, reprogrammed Xoanon, and then come back to UNIT HQ before anyone knew he'd been gone, and he didn't remember it afterwards because his mind was still a bit erratic post-regeneration. Which wasn't very convincing, since the Doctor's ability to steer the TARDIS was quite iffy at that point. As far as the aired serial goes, it always felt to me like they were fudging things with regard to the Doctor's past, treating it as something that had happened so long ago the Doctor barely remembered, but using the face he'd only had for a couple of years at that point. That always bugged me about it until I read the novel, and even that was a tenuous fix.