To treat pinworms, a doctor may recommend two doses of medication, 2 weeks apart and following strict hygiene practices to avoid reinfection. One medication, pyrantel pamoate, is available without a prescription. A doctor may not recommend medication for children under 2 years.