We can't explain this vast arguments in a few lines, but here are some rough guidelines.
- The dog barked means you've already talked about a dog, so it's "inu WA naita".
- However if you want to stress where that sound came from, you'll say inu GA naita, meaning naita no wa inu da = it has been the dog who barked (bad English?)
- A dog barked means that you still hadn't talked about a dog till now, so it's "inu GA naita".
- you use GA if the verb or the adjective needs it. E.g. ore wa inu ga suki; inu ga mieta!; inu ga kaitai na...
- If you make a contrast explicit or implicit between what a cat does and what a dog does, you'll say again "inu wa naita". Other ex. inu wa ita ga, neko wa inakatta (there was a/the dog, but there wasn't a/the cat).
- The contrast you create may be implicit, for instance you don't have to talk explicitly about the cat, and it may be a contrast with something you don't know.
- An implicit contrast may put some sort of limit (generally to what you know or can say). Usually "wa" will be translate with "at least". E.g. a student took something it wasn't yours, and someone saw it: "Did you see what he took from that desk?" "keshigomu wa nusunda" (he took at least an eraser)
- The negative form has an inherent contrastive nature, so you will usually say inu wa nakanakatta. However if you want to put a stress like that in the second point of this list you may say inu ga nakanakatta.
- In a dependent clause you'll use GA, no matter what: inu ga naita toki... inu ga naita kara... etc. Exceptios are sentence followed by to (e.g. inu wa naita to omou).
- "Dogs bark" or "the dog is man's best friend" or "A dog is a man's best friend" imply the use of the term "dog" as "generalized idea of a dog"; you're not specifically talking about a certain dog, so you will have to use wa again.
Hope it helps.
If someone can suggest other cases I'll add them in the answer. Thanks.