Formal is used in situations that are more serious. For example when you're in a job interview or emailing your professor. It can also be used when you're speaking to someone you don't know very well and want to make sure you sound respectful.
Informal is used in a more relaxed, everyday situation. This includes conversations with friends, family and other people you know well.