You use commas to split a sentence which isn't necessary for the original sentence to work, for example:
1) Imagine I have a brother - only 1 brother. Therefore, whenever I talk about him, you always know which brother it is, as there's only one. Imagine the following:
My brother, who is a programmer, won the competition.
The middle sentence here isn't really necessary for the original sentence to have its meaning and thus you can remove it and still have a perfectly valid sentence:
My brother won the competition.
In this case, the commas are added.
BUT, another case:
2) Imagine that I have many brothers and I say the following:
My brother who is a programmer won the competition.
Here I cannot erase anything from the sentence, because the "who" part further defines which brother I'm talking about for you to fully understand the meaning. In this case, you don't add any commas anywhere.