The Japanese have taken formal and polite language to a whole new level. The Japanese call it keigo, or honorific language. If you understand the rules of keigo, when listening to a conversation between Japanese you can determine the relationships within the group. Many factors come into play that affects the level of language to be used such as relative age, family relationships, working relationships, the situation, etc.
I'm often asked what level of formality to use. Fortunately, as foreigners, we are not expected to understand the rules of keigo, so you will not be expected to use the appropriate speech for the situation. Having said this, a little understanding of the basics can come in handy.
There are many ways to say "Thank You". I have listed a few of them below in increasing order from informal to more formal.
Arigato gozaimasu (current tense) or Arigato gozaimashita (past tense)
Domo arigato gozaimasu (current tense) or Domo arigato gozaimashita (past tense)
There are even more formal ways to say thank you, but they are for very formal occasions only and you won't have to use those. As a foreigner, a simple Domo or Arigato will be sufficient in all cases. However, if you wish to sound more "Japanese", you can use Arigato gozaimasu or Arigato gozaimashita. This is more formal, but not too formal and can be used for everyday speech.
Once again, there are many ways to say "Please". I have listed two of them below in increasing order from informal to formal.
Kudasai is sufficient for everyday speech. Onegai shimasu is normally reserved for more formal occasions.
I'm also often asked the difference between Dozo, and Kudasai or Onegai shimasu. Dozo also means "Please", but is used differently. When asking for something, such as asking for a glass of water at a restaurant you should use Kudasai or Onegai shimasu. If you are offering something to someone, such as offering a seat on the bus to someone or offering someone to enter an elevator before you, you should use Dozo.