In The Last of Us, survivors wear gas masks to bypass breathing in the spores found in enclosed places, such as a basement, to avoid becoming prone to infection. During world war always, everyone had their family gas mask kits that they put on when entering a spore-infested place.
Soldiers used one during the war to save themselves against the gas attack. Players get one in the quarantine zone. When people traveled across the United States, they found spores filled with places they had to cross to advance through an area. To avoid breathing in the spore, they had their gas mask while crossing.
Soldiers in the Boston QZ wear them as well when outside the protection of the walls, notably, while a special HAZMAT section of the military wears gas masks along with other protection when searching infected buildings for civilians. Some enemies (particularly among the Hunters and Bandits) that wear them have Molotov Cocktails. This can be an early warning to the player and should always be targeted first, if possible.
Most masks seem to be a variation of FM12 gas masks, without the top rope and green lenses. People need to use the right attachment for the filter (FM12 which has an attachment on both sides) even though they are right-handed, which is not useful aiming with long ranged weapons. The filter is not a standard FM12 filter.
However, another mask resembles an M40 gas mask used by the United States military. Some survivors, wear this model instead of the S10. This useful feature allows the wearer to drink from a canteen without removing the mask.