Learn first
Punctuation helps a reader follow meaning
A period ends a statement. A question mark ends a direct question. An apostrophe can mark possession or a contraction. A comma can separate parts of a sentence.
How to work it out Read the meaning first. Decide what job the mark needs to do; do not add a mark only because a word ends in s.
A separate example In a separate sentence, Is the gate open? needs a question mark. The gate is open. is a statement.
Use a comma after an introductory dependent clause. Join two complete clauses with a comma plus a coordinating conjunction such as but or so. Set off an extra detail with two commas when it interrupts a sentence. Do not join complete clauses with only a comma, or separate a subject from its verb.
Worked example
'When the bell rang, we packed.' begins with a dependent clause. In 'We packed, but the bus was late,' both sides of but could stand as sentences, so the comma comes before but.