When do you use a comma in a sentence

A comma is used in a sentence for various reasons, including:

1. To separate items in a list: I went to the store to buy apples, oranges, and bananas.
2. To separate adjectives: She has lovely, curly hair.
3. To separate clauses in a compound sentence: I went to the store, but I forgot my wallet.
4. To set off introductory words or phrases: However, I was still able to finish the work.
5. To separate a direct quotation from the rest of the sentence: "I love ice cream," she said.
6. To separate nonessential information or appositives: The book, which was written by J.K. Rowling, became incredibly popular.
7. To indicate a pause in a sentence for clarity or emphasis: Please, stop talking!