Pawn promotion happens when a pawn reaches the far end of the board, the eighth rank for White or the first rank for Black. The pawn is immediately replaced by a queen, rook, bishop or knight of the same colour, chosen by the player. Promotion is compulsory: the pawn cannot stay a pawn. It also does not depend on what has already been captured, so a player can have two or more queens at once.
The promotion happens as part of the pawn's move, not as a separate turn. You move the pawn to the last rank and replace it at once with the piece you have chosen.
You are not limited by which of your pieces have been captured. A player who has never lost their queen can still promote a pawn to a second queen, and there is no limit on how many pieces of a kind you may end up with.
Choosing anything other than a queen is called underpromotion. It is rare, because the queen is the strongest piece, but it is sometimes the only move that wins.
The knight is the usual reason, because it is the one piece whose movement a queen cannot copy. Promoting to a knight can deliver an immediate check or a fork that a new queen would not. Promoting to a rook or bishop is rarer still, and is usually done to avoid forcing stalemate.
Promotion is written as the pawn's move followed by an equals sign and the letter of the new piece. So e8=Q is a pawn moving to e8 and becoming a queen, and exd8=N is a pawn capturing on d8 and becoming a knight.
Know the rules and want to see where your games actually go wrong? Paste any game into the free analysis board for a move-by-move review, or explore how games begin in the opening explorer.