Entirely up to the DM.
The specifics of the campaign setting you use may have something to do with it, but ultimately, these kinds of decisions are entirely, purely, indisputably, wholly up to the DM's fiat.
Of course, if he doesn't provide you with the means to acquire DMG-suggested wealth by level, in terms of magic items primarily, then he can't rightfully expect you to handle everything of equal or higher Challenge Rating (unless he makes other arrangements or alters the monster CRs). That said, you're not entitled to receive such wealth by level, the Core Rules just assume you will have it for purposes of dealing with monsters and magical threats (and if you do not have somewhere close to the expected amount of magic items, then the Dungeon Master's Guide infers that the DM should adjust enemy CRs appropriately or choose his encounters carefully).
If you're playing in the setting of the Forgotten Realms (Faerun, aka Toril, aka Abeir-Toril), then you can probably just waltz into any Thayan Enclave, or temple of Gond (I think), or temple of Tempus, or the guildhalls of certain wizards' guilds (but not all; only some do business in magic item crafting and trading), tell the guy what kind of item you're looking for, and purchase it with the proper amount of gold.
The DM still decides if the merchant has that exact item, and whether or not he charges you the DMG-listed amount of gold for it, probably based on the region, its laws pertaining to magic, whatever rules the guild has regarding magic item trade/profits, and whether or not the merchant likes you.
Similarly, if you're playing in the setting of Eberron, you can just walk into an appropriate shop run by House Cannith or somesuch and ask for the magic item you want, pay the requisite amount of gold, and be on your way with the item. You might need to wait a few days or weeks though for them to custom-craft it, if they don't have a copy on-hand.
And unlike Forgotten Realms, Eberron has few mid-level or high-level Non-Player Characters, so there's not a lot of them around to craft magic items (especially not many ones beyond cheap scrolls and potions), so you'll have a tough time finding anyone around who has the item you want, or even just the capacity to craft that item on commission. So again, it's entirely up to the DM whether or not you'll be able to find the item you want.
If you play in the World of Greyhawk (Oerth) or other such place, it'll be tough to find and purchase any magic items in most places, beyond minor scrolls and potions.