The former is the "plain" form, and you use it in essays, with your friends, with your family, within quotation marks, etc.
The latter is "polite" form, and you use it with your Japanese teacher and other people who outrank you, with strangers, etc.
Speaking polite Japanese - Tae Kim's Japanese grammar guide