Commodore Stocker was technically flying a flag when taking command of Kirk's ship in "The Deadly Years". He might even have had his flag physically with him, ready to be flown at Starbase 10.
Commodore Mendez didn't really take charge of the ship in "The Menagerie". But Commodore Decker did, in "The Doomsday Machine". Neither of these characters would have had the physical flag packed, of course.