I'm playing a game of D&D 5e with some friends. Are firearms such as flintlock pistols and rifles allowed?
Possibly, it's up to the DM!
It is the DM, generally, who chooses the campaign setting, i.e. what "world" the players' adventures are going to take place in.
There are various published settings or a DM is free to create his own.
Most of the established settings use a more fantasy-medieval level of technology (with magic of course). Some settings - such as Eberron - are rather more advanced either technologically or in a 'magi-tech' kind of way.
A DM making his own campaign setting can choose any level of technology he likes, although the basic rules are geared more towards medieval fantasy. The Dungeon Master's Guide does contain optional rules on guns however, if you decide they exist in your campaign!
The DMG has optional rules for Firearms and Alien technology.
Firearms and Alien Technology are covered in DMG Chapter 9: Dungeon Master's Workshop (p. 267-268). All of the rules in that chapter are optional, and you are well advised to consider this part from the introduction of the chapter (p. 263):
This chapter contains optional rules that you can use to customize your campaign, [...] Some of them are variants of rules, and others are entirely new rules. Each option represents a different genre, style of play, or both. [...] Before you add a new rule to your campaign, ask yourself two questions:
- Will the rule improve the game?
- Will my players like it?
If you're confident that the answer to both questions is yes, then you have nothing to lose by giving it a try.
The Firearms table (p. 268) describes cost, damage, weight and properties of pistols, rifles and other firearms.