In The Last of Us, survivors wear gas masks to avoid breathing in the spores found in enclosed places, such as a basement, to avoid becoming infected. Joel always has a gas mask on him, and will put it on when he enters a spore infested place. Ellie does not need one due to her immunity.
A soldier wears one when Joel and Sarah attempt to reach the highway. The player obtains one in The Quarantine Zone, where Joel collects it, along with his backpack and 9mm Pistol. As Joel travels across the United States, he will find spore infested places that he must cross in order to advance through an area. To avoid breathing in the spores, Joel puts on his gas mask when crossing through. Some of Joel's fellow smugglers will wear gas masks should they be near spores, such as Tess, two smugglers in an abandoned building and Bill although the latter didn't necessarily require as he was in the uncontaminated outside air.
Soldiers in the Boston QZ wear them as well when outside the protection of the walls, notably Ramirez and her partner, while a special HAZMAT section of the military wear 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. Some of the Fireflies in St. Mary's Hospital who chase Joel when he attempts to escape with Ellie wear gas masks.
Most masks appear to be a variation of the FM12 Gas Mask, without the top straps and the lenses tinted green. Joel uses the right attachment for the filter (the FM12 having attachments on both sides) even though he is right handed, which is not useful aiming with long ranged weapons. The filter is not a standard FM12 filter.
However, other masks resemble the M40 gas mask that is used by the United States military. Some survivors, notably Bill wear this model instead of the S10. This useful feature allows the wearer to drink from a canteen without removing the mask.