My guess is ostensibly working out of Starfleet Command, but seconded as some kind of Starfleet Liaison officer to a variety of Federation diplomatic missions and embassies. That would let him get to know everyone and make him a natural candidate for a high-profile job like command of the Enterprise. It's also a useful background (when combined with his known tactical/combat/improvisational skills from the Stargazer Incident) given the Enterprise's intended role exploring deep space, making contact with new species and effectively acting as the Federation's voice in those contacts. You need someone diplomatically reliable in that role.