When there is a restrictive clause use "that" without comma.
Gems that sparkle often elicit forgiveness.
Cars that have hybrid technology get great gas mileage.
When there is a nonrestrictive clause use "which" with comma.
Diamonds, which are expensive, often elicit forgiveness.
There was an earthquake in China, which is bad news.
Merriam-Webster's Collegiate Dictionary (10th edition), regarded by most writers as the authority on such matters, tells us that it is now common for which to be used with either kind of clause, while thatmust be used only for restrictive clauses. In fact, though, careful writers continue to make the distinction
we describe above. Attorneys are taught to use which for nonrestrictive clauses and that for restrictive clauses so as not to cause a misreading in legal documents. It seems just as important that we work to avoid misreadings in all writing, not only in situations when a legal ruling might be at stake.
1. Our house [that
has a red door and green shutters] needs painting.
2. Our house, [which has a red door and green shutters],
3. The classrooms [that
were painted over the summer] are bright and cheerful.
4. The classrooms, [which were painted over the summer],
are bright and cheerful.
sources: http://www.getitwriteonline.com/archive/103103whichthat.htm and http://www.quickanddirtytips.com/education/grammar/which-versus-that-0