1. He likes warm colors such as red and yellow.

2. He likes warm colors for example red and yellow.
3. He likes warm colors, for example red and yellow.
------------------------
Which one is similar to #1? Do we have to put a comma before 'for example'?

You need commas after "colors" in all sentences, and then they'll all be right.