Sometimes owners don't hear the bike - the dog might, but it's up to the owner to control the dog. If you can see a dog slow down and make a noise, or shout hello to attract the attention of the owner so they can get the dog under control before you go past. Obviously, as in this case, if you can't see the dog till it's nearly in your wheels there's not a lot you can do, except brake to slow down. Dogs are unpredicable, (and silly) like any animal, so if you did all you could, it's just one of those things. You slowed down before striking it, so there's a good chance of it (and you!) not being injured.
My parents dog needs to knock breakable things off tables with her tail, bump into something (the door) and chase the paper boy on his bike at least 120 times before she learns not to do it again, so don't bank on it being any more sensible next time!