"Help yourself to sweets from the jar which is on the top shelf" - to specify WHICH jar you can nomm from.
"Help yourself to sweets from the jar that is on the top shelf" - there's only one jar, and the useful information tells you where it is.
Yes, you were right - you've got these the wrong way round.
Actually, on seconds thoughts, they're not the wrong way round exactly, but the distinction isn't very clear in your example...
"Help yourself to sweets from the jar, which is on the top shelf." - in this case, the non-restrictive clause "which is on the top shelf" is providing extra information that isn't strictly needed to identify the jar. "Help yourself to sweets from the jar. By the way, the jar is on the top shelf."
"Help yourself to sweets from the jar that is on the top shelf." - here the restrictive clause is telling you that you're allowed to take sweets from this jar but no other. It's called a restrictive clause because the extra information restricts the number of jars that you could possibly be talking about. "Help yourself to sweets from the jar that is on the top shelf but keep your grubby mitts off the jar that is on the bottom shelf."
But as per other answers, it's not a distinction that many people either understand or care about these days. You can use "which" or "that" interchangeably and people will understand you. Using the wrong one is unlikely to cause any ambiguity.
d.