That is used for necessary information and has no commas.
A necessary phrase (known as a restrictive clause) uses the word ‘that’ and is not surrounded by commas. If you remove the phrase it changes the original meaning of the sentence. Example: The novel that Sarah Bell wrote didn’t sell well.
Which is used for unnecessary information and is surrounded by commas.
An unnecessary phrase (known as a non-restrictive clause) uses the word ‘which’ and has commas. If you remove the phrase it does not change the original meaning of the sentence. Example: The Twilight novels, which were for young adults, were adapted for film.
From The Plain Language Programme by Amanda Patterson