It's a young child they don't exactly know when to keep words to themselves. So I'd just let the kid know that saying things like that "isn't nice" and "can hurt others' feelings". No need to get all dramatic about it or something.
Whatevs. I wouldn't really care. Ugly is such an unoriginal insult, it loses its bite. I can see really young girls thinking that, though, because my hair is much shorter and that can be seen as mais boyish.
Say nothing and walk away, or let someone else know that the little kid called you ugly and maybe that someone may sort out the little kid. The little kid is little, but why call someone ugly? They may look ugly, but it is wrong to call someone ugly.