Japanese formal language (also called honorific or polite language) is simply put, almost a different language from the casual Japanese language. But don't find this fact intimidating! For beginners, a simple rule is if a sentence ends with です、でした、ます、ました, then it's formal. The equivalent of casual Japanese would be だ、だった. The casual language is only used with your friends and peers. To everyone else (someone older than you, strangers, customers, etc.) you would use the formal language.
Here's an interesting article you might find helpful: http://www.japaneseprofessor.com/lessons/beginning/politeness-and-formality/