This is a confusion I tripped over a lot in the past. I think I’ve got it now, but let me know if you disagree.
“Which” and “That” are used in a number of contexts, but the one I’m talking about is sentences like This is the house [which/that] Jack built.
Sometimes, you can get away without using either word. This is the house Jack built isn’t wrong and saves you the bother of choosing between which and that. Also, if you’re talking about people, you should always use who (or whom). I saw a bumper sticker the other day – “Trucks for people that work hard”. This is either a very clever play on words (the trucks work hard) or it’s just plain wrong (if the people work hard, it should say who).
But, back to the question of which or that. Microsoft Word has opinions – it gets upset if one types which without a comma in front. But adding a comma isn’t actually the whole answer.
WHICH is for subclauses. It should be preceded by a comma, but only because the whole sub-clause needs commas to bracket it off. A sub-clause is a part of the sentence that can be removed and the sentence would still make sense. For example, “The fork, which had previously been on the floor, was now on his plate.” If you take out the subclause, there’s still a sentence there: “The fork was now on his plate.”
THAT is for all other times. No need for commas, this is part of the main statement and can’t be removed. “On his plate was the fork that had previously been on the floor.”
So, this is the house that Jack built.