There is no simple answer to this. There are cases in which there is general agreement - for example with defining and non-defining clauses, but very often there is relatively free choice.If you are writing for publication, your publisher's editors will have their own style guide, and will edit your work accordingly. Apart from that, one simply has to use one's own judgement, based on what one has been taught at school and on one's own experience of reading what native speakers have written.
The good news is that most speakers of British English do not get too concerned about whether or not people use the Oxford comma, or whether or not a comma between two independent clauses is a virtue or a sin.
If you are writing for an American English readership, then it might be a good idea to obtain a respected style guide. Barb or one of the other Americans here can probably recommend a good one.
Student or Learner