As your kid has seen live worm during defecation, indicates worm infestation.
De-worming is required usually with drugs like Albendazole
or febendazole. De-worming has to repeated every 6 months as de-worming drugs kill adult worms, they do not kill the eggs.
De-worming should be done to all the family members and continue maintaining good personal hygiene.