Read the sentence out loud. Take note of the natural pauses you make in the reading. These places are likely spots to insert commas. For example, you would read the following sentence like this: "We went to the store (pause) bought milk and cheese (pause) then went back home." The sentence would look like this: "We went to the store, bought milk and cheese, then went back home."
Substitute the comma (or pause) with the word "and." The example sentence could have been written like this: "We went to the store and bought milk and cheese and then went back home." That is grammatically correct, but it is awkward -- replace two of the "ands" with commas.
Determine whether the phrase in the sentence can be taken out without changing the grammatical structure of the sentence. If so, then it is appropriate to add commas to set off that phrase. If you can lift out the phrase and what remains is still a sentence, then the phrase needs commas around it. In the example sentence: "We went to the store, bought milk and eggs, then went home," you can take out the phrase within the commas. It would then read "We went to the store, then went home." The sentence is still correct without the phrase.
Eliminate commas that come between a noun and its verb. This is called a comma splice. An example of a comma splice, using the example sentence, would be: "We, went to the store, bought milk and eggs, then went home." "We," the noun, is separated from "went," the verb, resulting in a comma splice. Make sure there are no commas between nouns and their verbs.