When a word like and, or, and but (called conjunctions) joins two standalone "sentences," you should put a comma before it.|
(The real name for a standalone "sentence" within a longer sentence is independent clause.)
Put a Comma before a Conjunction If It Joins Two Independent ClausesWords like and, or, and but are known as conjunctions. (There are other conjunctions, but these three are by far the most common.)
(NB: Conjunctions are often used in lists, and the ruling about using a comma before a conjunction in a list depends on whether you're following US or UK writing conventions, or whether you're an advocate of the Oxford Comma.)
This page is about conjunctions that are used to merge two standalone "sentences" (or independent clauses as they're really called) into one using a conjunction. This is a very common practice. When a conjunction is used in this way, it is usual to place a comma before it.
"He is a great swimmer."
"He prefers to play golf."
(This is two standalone "sentences" (i.e., independent clauses) merged into one with but. Therefore, a comma is required before but.)
"I may consider your plan"
"I may disregard it."
(This is two independent clauses joined by the conjunction or. Therefore, a comma is required before or.)
"The applicant must be able to tell jokes and sing."
"She must be able to dance."
(This is two independent clauses joined by the conjunction and. Therefore, a comma is required before and.)
Read more about commas in lists.
No Comma Necessary for Short ClausesIt is also worth knowing this:
If the two "sentences" (known as independent clauses) are very short, it is acceptable – for style purposes – to omit the comma.
TOO MANY COMMAS? USE A SEMICOLON
When indepedent clauses containing commas are merged together using a conjunction, it is possible to use a semicolon instead of a comma before the conjunction.
However, this is quite an outdated practice in modern writing. Use it very sparingly — if at all.