While many people puzzle over whether to use that or which, the basic rule is pretty simple: use that when providing essential information and which when providing extra information. In order to implement this rule, you need to look beyond the specific sentence you’re writing and think about context.
That
For example, suppose you know that I have two paintings, one on display and one in storage. If we’re discussing how to take care of artwork, I might think it’s important to distinguish between the two paintings, so I would use that to specify which one I’m talking about, as in the following sentence:
Every other week, I dust the painting that is hanging in my office.
Now, suppose you know that I only have one painting and that it is on display. If we’re discussing how to take care of artwork, I don’t need to specify where my painting is, because you know it’s on display, and that’s what’s relevant to how I clean it. Therefore, in this situation, the location of my painting is extra information, so I would use which (with a comma):
Every other week, I dust the painting, which is hanging in my office.
So, why is this the rule?
Well, pretty much anyone who has seriously studied English that it’s actually not. This so-called rule was invented in the early twentieth century by some prescriptivists who themselves admitted that most good writers did not follow the “rule” and that the “rule” had plenty of exceptions. Their argument was that distinguishing between *that* and *which* would help clarify what was essential information and what wasn’t. However, if you click on the links above, you will find that this idea has been debunked – largely because people have no trouble figuring out what is important based on context and commas.
Which Which
It’s true that that is usually used only for essential information, but which may be used – without confusing anyone or sounding odd – for either essential or extra information. So really, if in a particular context I needed to specify the painting I was talking about, the following would be a perfectly clear and normal-sounding way to do it:
Every other week, I dust the painting which is hanging in my office.
(Notice the lack of comma – unlike the word which, the comma often does make it seem like the information is inessential.)
When reading, you don’t need to be too concerned about the difference between which and that because you’ll probably be able to tell from context whether the given information is essential (also, a comma before the which is generally enough to indicate that information is inessential). When writing, you might want to keep this “rule” in mind, because in some formal contexts you might be expected to follow it – although it’s good to realize that in your personal writing, you can be more flexible without being wrong.