I heard in a youtube video that you are not allowed to talk to your opponent unless you are saying check or checkmate. Obviously, this rule is loosely enforced in casual play, but is this true?
According to the FIDE Laws of Chess, rule 11.5:
It is forbidden to distract or annoy the opponent in any manner whatsoever. This includes unreasonable claims, unreasonable offers of a draw or the introduction of a source of noise into the playing area.
So you can't just say whatever you like to your opponent while you're playing an official game. It's distracting, both to your opponent and to anyone else trying to play in the room.
Check or checkmate is not the only thing you can say, however (and at high levels, almost nobody says check.) Obviously, you're allowed to point out that the game is over because the position is drawn by rule or one player is out of time. A draw offer is ordinarily spoken aloud. You must also say something like “j’adoube” or “I adjust” when adjusting a piece. In USCF matches, I've generally told my opponent if they make an illegal move, so they can correct it, rather than stopping the clock and summoning the tournament director. I've also quietly pointed out some other rules to my opponent when they came up, such as if they touched a piece and then moved a different piece.