Agree with ScuttleButter as usual.
I understand that the knee-jerk reaction is to rehome, it's a common one as ScuttleButter says and one which can swing either way depending on how the rehoming is done. Get your dog into a good rescue and they will assess, sort any issues and generally not rehome where there are small children - I say generally as we DO see cases where clearly the dog is not at fault, as in the situation with your friend's child pestering your dog and pulling his tail.
BUT... bear in mind please that rescue spaces are hard to come by for even the most uncomplicated dog, ones with a problem to address are harder still to place. For goodness sakes, I beg of you, if you decide to rehome seek a rescue which is no kill and which will rehabilitate - I and others on here can help with identifing one if that''s your decision.
A bad owner will rehome to a disreputable rescue or rehome privately or just take the dog to the vet to be killed... as I said it can swing either way. The reason why I am saying this is to prove the point that a dog in this situation is far from beyond redemption - it depends, again as ScuttleButter said, whether you are willing to put in the work and seperate and supervise your DC and the dog (not saying that there was no supervision here, obviously there was, but seperation from clumsy DC and dog is equally clearly necessary).
Personally, speaking as someone who has taken on problem dogs and who has DC, and who also knows that it CAN be done - and tbh the joy and pride of overcoming canine issues - I would go down the seperation/stairgate/playpen (for pup or DD, depends on your POV here, I used playpens for my DDs but know that many MNers consider them the devil's work!), and so on. My own view is that a repeat is totally avoidable and that you are able to come out with a safe daughter and happy, cared for dog.
I must say though, without wishing to turn this into a bunfight, that you would be not only perfectly WITHIN your rights but also perfectly right, responsible and sensible to pull the parent of the child who pestered and pulled your dogs tail up BLOODY hard about allowing their DC to do it and perfectly within your rights to pull the DC up and stop them if the parent/s didn't, for everyones sake, dog and child included. Far rather your considered rude by the (very rude and silly) parent/s themselves than have their child injured or feel obliged to rehome your pet because of their irresponsibility. Don't feel bad about telling other people's children to behave, please, it's for all your sakes.