that, which. Use that, not which, in a restrictive clause — a clause necessary to the reader’s understanding of the sentence: The town that the pitcher calls home is tiny Hawley, Pa. (The sentence serves no purpose without that the pitcher calls home.) Note that there are no commas around the clause. In a nonrestrictive clause — one providing added information, not essential to understand the sentence — use which, preceded by a comma: Hawley, Pa., which the pitcher calls home, is tiny. (The sentence is understandable without which the pitcher calls home.)Claims "Grammar Girl": "A quick and dirty tip (with apologies to Wiccans and Hermione Granger) is to remember that you can throw out the 'whiches' and no harm will be done. You use which in nonrestrictive clauses, and if you eliminate a nonrestrictive clause, the meaning of the remaining part of the sentence will be the same as it was before."
CMOS basically agrees, though conceding that "Some people use 'which' restrictively, which is more or less okay (and popular among writers of British English) as long as no commas are involved."
Here's a challenge that you can take, which is a nice test of this distinction. Does it matter?
Survey SAYS! "The difference between 'that' and 'which' is something that I ..." care about and get right (44%), care about but get wrong (33%), or ignore (21%).