Use that when the clause is essential to identifying what you mean: 'The report that arrived late was mine.' Use which with commas when the clause is extra detail you could delete: 'The report, which arrived late, was mine.' The commas do more work than the word choice does.
The core difference is essential vs extra
Some clauses narrow down which thing you are talking about. Others just add a fact about a thing already identified. English marks the second kind with commas.
'The houses that face the sea sold first' means only the sea-facing ones sold first. 'The houses, which face the sea, sold first' means all of them face the sea and all of them sold first. The meaning genuinely changes.
The test
Delete the clause and see what breaks. If the sentence still means what you intended, the clause is extra — use commas, and use which. If deleting it makes the sentence too vague or plain wrong, the clause is essential — no commas, and that is the safe choice.
A second check: try reading the clause in a lowered, parenthetical tone of voice. If it sounds natural as an aside, it wants commas.
How much is this rule actually observed?
Here is the honest position. Non-essential clauses take commas and which — that part is real punctuation, and every careful writer follows it. But the reverse, the claim that essential clauses must take that and never which, is a style preference rather than a rule of grammar.
American style guides, particularly those following Fowler's recommendation, enforce it strictly, and US editors will change your essential which to that. British writing has never observed it consistently: 'the book which I lent you' is unremarkable in British English and appears throughout respected prose. Nobody misunderstands it.
Practical advice: always punctuate correctly, and use that for essential clauses if you are writing for an American publication or want to be uncontroversial. Do not lie awake over an essential which.
Where the choice is forced
- After a preposition, only which works: 'the room in which we met', never 'in that we met'.
- Referring to a whole clause, use which: 'She resigned on Monday, which surprised nobody.'
- For people, use who: 'the neighbour who complained'. That is acceptable for people but can sound brusque.
The common mistake is a hybrid: 'The report, that arrived late, was mine.' A comma followed by that is wrong in every style. Pick commas plus which, or no commas plus that.