Training pants are needed until the child can keep the training pants dry during the day and can get to the bathroom or toilet before they wet their training pants.
Once the child has been able to get to the toilet on time and is able to hold in his/her poop or pee successfully then the child can go without training pants.
My son wore training pants until he was 7 years old as a just in case measure as sometimes he would wet the training pants before he made it to the restroom.
Most children won't need training pants past age 4 but my 7 year old son wore them as a just in case measure although most times he'd make it to the restroom on time.