(I'm not a teacher.)
They're all correct. The difference is the type of clause. The commas denote a non-restrictive clause, which describes the subject. When there is no comma, it is a restrictive clause, meaning that it defines the subject. The difference seems subtle, but it can completely change the meaning of a sentence. I'll demonstrate with an example other than those which you provided:
(a) The man who talks is a happy man.
(b) The man, who talks, is a happy man.
Sentence (a) means that only men who talk can be happy (defining). Sentence (b) is talking about a specific man who is happy (describing).
Is there still some confusion, or did that clear everything up?