Punctuation of Subordinate Elements
Nonrestrictive or merely parenthetical sentence elements must be set off by commas. Do not set off restrictive elements.
Translation: a restrictive sentence element (a clause, a phrase, or a word) restricts (i.e., defines or limits) the meaning of the word it modifies.
A nonrestrictive element causes no such restriction; it adds information without limiting the meaning of the sentence.
Still confused? A looser translation: if you're questioning whether or not to enclose a phrase in commas, ask yourself whether or not the phrase in question limits or describes the noun it follows. If it limits the noun, it is restrictive. In that case, it is not enclosed in commas. If it describes but does not limit the noun, it is non-restrictive. In that case, it should be enclosed in commas.
Does all this give you a headache? Try these examples:
The members of the faculty, who read the article, were shocked by its bad style.
The clause who read the article is set off by commas; therefore, the reader knows that all members of the faculty read the article and therefore the clause is nonrestrictive.
In the following sentence, the identical phrase is not enclosed in commas:
The members of the faculty who read the article were shocked by its bad style.
In this sentence, the phrase" who read the article" is restrictive; it defines (or restricts) the specific sub-set of faculty who read the article. The reader understands that not all members of the faculty read the article and that only those who read it were shocked.
He answered all the questions, which were on geography.
--all the questions were on geography, and therefore, the phrase "which were on geography" is a nonrestrictive element (merely adding the information that "all the questions" were on geography) and necessitates a comma before it.
He answered all the questions that were on geography.
--not all the questions were on geography, so the phrase "that were on geography" is a restrictive element (indicating that he answered only geography-related questions) and needs no comma. However, in the case of the sentence--
The question of that vs. which is related. In spoken usage, the pronoun which is used both in restrictive and non-restrictive clauses. However, many writers, in an attempt to minimize the confusion association with restrictive and non-restrictive clauses, reserve that for restrictive clauses and which (with commas) for non-restrictive clauses. Consider the sentence
The sweater, which my roommate tore, is in the closet.
This sentence indicates that there is only one sweater in question, and it is in the closet (the fact that it was torn and who tore it are unessential to its location, which is the main idea of the sentence). Substituting that for which, however, gives us this sentence:
The sweater that my roommate tore is in the closet.
This sentence implies an abundance of sweaters, of which the one the roommate tore is in the closet. Therefore that my roommate tore qualifies the sweater in question and must not be de-emphasized by commas.
For more information on that vs. which, refer to Commonly Confused Words.