Here are the basic rule of when to use commas:
1. To separate the words in a series or list.
My grocery list included vanilla extract, pickles, and Frosted Flakes.
2. Before the coordinating conjunction (remember the FANBOYS!) when forming a compound sentence
Vance wanted to stay up late to watch King Kong, but he fell asleep at 8:30.
3. To separate a dependent clause from an independent clause when the dependent clause comes first.
If she finished her homework early, Lee would have time to play Call of Duty.
4. To set off introductory words, phrases, and clauses.
Sadly, we had to cancel our vacation to Dollywood.
5. To set off parenthetical elements like appositives, interrupters, and adjective clauses that aren't essential to the sentence's meaning.
My dentist, Dr. Cordula P. Willifarth, says I need to floss more often.
Randy, of course, is running late again.
Karen, who has a long history of kleptomaniac behavior, stole her neighbor's riding lawn mower and drove it to Wisconsin.
6. To separate dates and place names.
Oslo, Norway, is home to many mischievous trolls.
December 7, 1941, is a date that will live in infamy.
7. After the greeting in a friendly letter/email, and after the closing in all letters/emails.
Dear Uncle Phil,
8. To set off nouns in direct address.
Jack, your feet smell awful.
I told you, Tina, we have to pick up the tickets at the box office.
9. To set off direct quotations in a sentence.
"The Rangers game starts at 6:30," said Alan.
The girl behind the counter asked, "Do you want fries with that?"
10. To set off interjections.
No, you can't have a pony for Christmas.
11. To separate adjectives of equal importance.
The tall, handsome man walking toward them had to be an undercover cop.
12. In numbers of more than three digits.
1,999 22,566 525,600