If your sentence has a clause but doesn’t need it, use “which”. (Nonessential clause) (A little trick to help us remember: We don’t need “witches”—Hexen!!!).
If the sentence needs the clause, use “that”. (Essential clause)
Example 1
The old house, which (by the way) is one of my favourites, is in a bad condition.
The old house is in a bad condition. The type of antibiotic that my doctor prescribed made me feel bad.
The sentence without the clause “that my doctor prescribed” doesn’t make sense: The type of antibiotic made me feel bad.
Example 2
• Our house, which (by the way) has 3 bedrooms, is located near the sea.
• Our house that has 3 bedrooms is located near the sea.
The first sentence discusses the location of your only house and it just so happens to have 3 bedrooms. And lucky you, it’s near the sea.
The second sentence points out that the house you own with 3 bedrooms is located near the sea. This means you have more than one house, lucky devil. “That has 3 bedrooms” is how you distinguish between your many homes.