Commas are a minefield for many. I have come to notice that children's books don't use them correctly, and I'm sure this is why most people never fully learn the rules, although they're not always hard and fast.
It would take ages to type out all the rules here. Google "comma usage", which will give you a good start. Knowing when not to use them is as important as knowing when to.
Some basics:
Lists
I need apples, bananas, oranges, and grapes.
The last comma is optional, but be consistent in the same piece of work.
If the list is very long and complex, you can use a semicolon to separate concepts e.g.
I need apples, red, green, and yellow; grapes, red and white; potatoes, maris pipers, king edwards... etc.
The comma between sentences that could stand alone
I love oranges. I love apples = I love oranges, and I love apples.
Not all sentences with and or but need a comma:
I loves oranges and apples.
I love oranges but only if they're easy to peel.
I love drinking water and eating oranges.
The comma after an introductory word or phrase
Hungrily, he ate the apples.
Because he loved apples, he ate them hungrily.
He ate the apples hungrily.
Commas around additional info
"British people who eat apples are crazy."
This means that if you are British and you eat apples, you are crazy.
"British people, who eat apples, are crazy."
This means British people are crazy and they also eat apples.
"John' sister Tina loves apples"= John has more than one sister.
"John's sister, Tina, loves apples"= John has one sister.
The 'which' comma
Not need when which could be replaced with that e.g.
He likes apples that taste good.
He likes apples which taste good.
But needed here:
He likes apples, which taste good with sugar.
-Using 'However'-
He did, however, like oranges.
However sometimes needs a semicolon before it, e.g. I don't like apples; however, I will eat oranges.
To give clarity
This is the main purpose of commas and usage can be flexible.
For instance, we usually put a comma after a negative "because".
Positive because:
I went to the park because I was hot.
Negative because:
I didn't go to the park because I was hot.
This can be read 2 ways.
Did they mean:
I didn't go to the park, because I was hot.
Or
I didn't go to the park because I was hot. I went for another reason.
-Adjectives-
Comma needed:
I love ripe, juicy oranges.
I love juicy, ripe oranges.
Comma not needed when you can't swap the adjectives:
I love big red apples.
I like bouncy tennis balls.
Comma needed for clarity:
"Have you heard about the big red apple shop?"
Is this a big, red, apple-shop?
Or a big, red-apple shop?
Or a big-red-apple shop?