Well, I’d say commas are mostly used in places where you would naturally pause in a sentence.
Sometimes after は, but mostly after contrastive conjunctions like が, けど, ても, のに, or other conjunctions like から and ので. Also after a verb in 中止形.
Or simply in various places to make the sentence more easily understandable and less ambiguous. When you have longer sentences they simply break up the flow a little and make things easier to parse.
That’s actually also related to why commas weren’t really used that much historically in Japanese, because using them implied that the reader was stupid and wouldn’t understand you without the “help” of commas. Luckily we’re past that, and they’re used in various places to make stuff easier to read.
Also, I don’t know if there’s actual rules that you can learn, I simply picked these up while reading.