Use a comma to set off introductory elements, as in "Running toward third base, he suddenly realized how stupid he looked."
Use a comma to separate the elements in a series (three or more things), including the last two. "He hit the ball, dropped the bat, and ran to first base." You may have learned that the comma before the "and" is unnecessary, which is fine if you're in control of things. However, there are situations in which, if you don't use this comma (especially when the list is complex or lengthy), these last two items in the list will try to glom together (like macaroni and cheese). Using a comma between all the items in a series, including the last two, avoids this problem. This last comma—the one between the word "and" and the preceding word—is often called the serial comma or the Oxford comma. In newspaper writing, incidentally, you will seldom find a serial comma, but that is not necessarily a sign that it should be omitted in academic prose.
Use a comma + a little conjunction (and, but, for, nor, yet, or, so) to connect two independent clauses, as in "He hit the ball well, but he ran toward third base."