A dash (technically called an em dash) and a comma can both be used to set off parenthetical expressions, appositives and other words and phrases. The biggest difference between the comma and the dash is the amount of emphasis they each suggest. As a general rule of thumb, use dashes to express more emphasis and commas to express less. Here you will see examples of sentences that are better punctuated by dashes than by commas.
Use dashes to set off parenthetical phrases. For example:When you come in--or go out--don't forget to shut the door.I am going to buy a new car--if I get that raise.In these examples, the dashes put greater emphasis on the enclosed phrases than commas would. The reader experiences a stronger break in thought than he or she would have if commas had been used.
Use dashes to set off appositives. For example:Two artists--Van Gogh and Picasso--are being featured at the museum.My brother--a doctor--recommends taking a multi-vitamin.Again, the dashes put greater emphasis on the enclosed phrases than commas would. In these examples, this adds an element of importance to the information contained within the dashes.
Use a dash to cut off dialogue. For example:"I never said--" he began.When typing a completed sentence, a comma precedes the closing quotation mark and the attribution. When a thought is left unfinished, however, a dash should be used instead.