For the most part, Team Fortress 2 takes place in New Mexico and the USA during the late 60s and early 70s. However, the game also takes place in other parts of the world. The characters that are part of the game are from different parts of the world.
The Scout is from Boston, USA, the Soldier is from the Midwest, the Demoman is from Ullapool, Scotland, the Heavy is from Russia, Engineer is from Bee cave, Texas, the Medic is from Stuttgart, Germany, the Sniper is from Australia but was born in New Zeland, and lastly the Spy is from France. However, it is not known where the Pyro is from. If you are familiar with different accents, you can easily pick up where all the in-game characters are from.
With all that said, there is no official story mode or single-player campaign available for Team Fortress 2. While the storyline is revealed for most games from the single-player campaigns, it is not the case for Team Fortress 2. The storyline for Team Fortress 2 is revealed to the community through several comics and the Meet the Team videos. These sources answer questions like “where are the characters from” and “where and when does Team Fortress 2 take place”. Along with comics and videos, the storyline is also revealed with media that comes bundled with major updates. There have been several major updates over the years that revealed a lot about the storyline of the game.