It would seem to have existed prior to the final assemblage of United Earth, was it always a part of it?
We know, from TNG: Attached
, that all the nations of Earth finally came together into one world government (United Earth) in the year 2150. That was also the year that the final selection for the captiancy of the NX-01 was made, with Archer being the final choice.
We also know, from ENT: First Flight
, that Starfleet was around at least as early as 2143.
So, it does seem as through Starfleet was part of the United Earth structure even before all the nations were on board.
My guess is that Starfleet existed, in some form, from as early as 2119, when the Warp Five Complex was opened.
However, given that it took them over thirty years to develop the Warp Five Engine (probably due to Vulcan interference) I'd also say that Starfleet was still was an infant by the time Archer joined up.