In languages that have both familiar and formal forms of 'you', how do you when to use each?

And not even about countries. In Venezuela alone there are plenty of regional differences. In the Andes and the Llanos the use of the formal “usted” is expected even within the family (children to uncles, for example) while this is not the case along the coast or the capital.

Most Venezuelan will treat their same-age friends informally. In some parts of Colombia men don’t talk to each other informally at any age (it is seen as a gay thing). To me it is funny seeing 9-year olds talking to each other in the formal.

Here in Puerto Rico, it is my personal impression that men talk to women informally a lot more often than women to men.
When in doubt. Always use formal until asked to be informal. Nobody will be offended or think less of you for being formal.