how do you know whether to use , or ; in sentence that need them?

http://owl.english.purdue.edu/handouts/grammar/g_commacomp.html

Comma uses: http://grammar.ccc.commnet.edu/grammar/commas.htm

LOTS of these!!

Semicolon uses:
http://grammar.ccc.commnet.edu/grammar/marks/semicolon.htm
The basic use of semicolons is to separate independent clauses, but there are other uses, too.

To determine whether to use a comma (,) or a semicolon (;) in a sentence, you need to understand the rules governing their usage. Here's a breakdown of the main guidelines:

1. Separating items in a list:
- Use a comma to separate words, phrases, or clauses in a list of three or more items.
Example: She bought apples, oranges, and bananas.

2. Separating independent clauses in a compound sentence:
- Use a comma before coordinating conjunctions (and, but, or, nor, for, so, yet) that connect two independent clauses.
Example: I went to the store, and I bought some groceries.

3. Indicating a pause or a brief interruption:
- Use a comma to indicate a brief pause or to set off introductory or non-essential information.
Example: However, I'm not sure if it will rain tomorrow.

4. Joining closely related independent clauses or complete sentences:
- Use a semicolon to join two closely related independent clauses without a coordinating conjunction.
Example: She sings beautifully; her voice is mesmerizing.

5. Separating items with internal punctuation:
- When items in a list contain internal punctuation (such as commas), use semicolons to separate them.
Example: I need to visit Paris, France; Rome, Italy; and Berlin, Germany.

Remember that punctuation rules can sometimes be flexible, and there may be variations based on style guides or personal preferences. It's always a good idea to consult a grammar resource or refer to a style guide for specific cases or writing conventions.