This is a question that comes up frequently when a parent has a child of the opposite gender and he or she needs to use the bathroom. Around age 6 or 7, children can use the toilet by themselves without any assistance. When it comes to allowing a child to use a public restroom by himself, however, the issue isn't about ability as much as it is about safety.
Child safety experts generally agree that most kids are not able to handle an emergency or threat to their safety until around age 10. That's why it's best to avoid letting your child use public restrooms in large areas, such as those found in stadiums or movie theaters, or bathrooms with multiple entrances, without you. Either take your child with you to the bathroom you use, or better yet, try to find a family restroom. (Women's restrooms offer more privacy than men's, so a dad traveling alone with a daughter will face a trickier dilemma; in that case, finding a small restroom, where he can closely monitor his daughter from outside the door would be the best bet.)
The same goes for using public bathrooms in smaller areas. For instance, if you are at a restaurant where there is a small restroom with one entrance, you can let your grade-schooler go in alone but under close supervision: Keep one foot in the door so that you can keep talking to your child. Have him or her use a stall close to the door. And be sure to remind your child not to talk to anyone or let a stranger approach him while he is using the facilities.