One of the simpler rules which students often forget about is the one about using commas with non-essential elements in a sentence, and not using commas with essential elements in a sentence.
Let’s have an example:
1. My sister, who works in IT, is coming to visit me tomorrow.
2. The person who is speaking is my sister.
In sentence 1 you should be able to see that the clause ‘who works in IT’ is not essential to the meaning of the sentence. It is just a bit of extra information about my sister, the important information is that she is coming to visit me. Because this is a non-essential element in the sentence we use commas (this is called a non-defining relative clause). In sentence 2 the clause ‘who is speaking’ is essential to the understanding of the sentence as it defines which person is my sister. It is an essential element in the sentence (called a non-defining relative clause).
Further reading: from Purdue and read about this and other uses of commas.