The position of a comma can often reflect the sense in which the word is being used.
Taking the word but for example, if it is being used to join two independent clauses together then there should be a comma before but.
I used to be a werewolf, but I’m much better naaaoowwwwwww!
If the clauses aren’t fully independent, i.e. would not make sense read separately, then there is no comma.
I used to be a werewolf but feel better now, thanks.
However, just to keep things interesting, if there is no comma before the but it might also mean the word is being used in a different sense.
I was house-broken but for the occasional soiling of the rug.
In this instance, but is being used to mean “except for”, and there is no comma. You can usually spot this form of but as it followed by the word for.
Comma after but
This would generally be incorrect unless there was some extra phrase or information being added straight after it, using commas. This is more of a coincidence in word order rather than a function of the word itself.
I used to be a werewolf but, due to the increasing number of woodcutters with sharp axes these days, decided to give it up.
Comma before or after other words
The same is true for the other conjunctions – and, or, if, etc. If the sentence is combining two independent clauses together then the comma should appear.