The usage concerns two types of clause, restrictive and non-restrictive. A restrictive clause is one that limits, or restricts, the scope of the noun it is referring to. Take these examples:
The house that is painted pink has just been sold.
The house, which is painted pink, has just been sold.
In the first one, the clause “that is painted pink” is a restrictive clause, because it limits the scope of the word “house”, indicating that the writer doesn’t mean any house, only the one that has been painted in that particular colour; if he takes that clause out, all that’s left is The house has just been sold: the reader no longer knows which house is being referred to and the sentence loses some crucial information. In the second example the clause is non-restrictive: the writer is giving additional information about a house he’s describing; the clause which is painted pink is here parenthetical — the writer is saying “by the way, the house is painted pink” as an additional bit of information that’s not essential to the meaning and could be taken out.
Here’s another example:
Another cause of stress is a traumatic event that is out of the ordinary and has a major impact on the person’s life.
The argument here is that the clause “that is out of the ordinary and has a major impact on the person’s life” modifies and constrains “event”. It’s not just any event but one specific type of event, to the extent that the whole block from “event” onwards forms one idea. The clause is restrictive.
Restrictive clauses are introduced by 'that' and are not separated from the rest of the sentence by commas.
Non-restrictive clauses are introduced by 'which' and must be separated by commas from the rest of the sentence to indicate parenthesis.