It is preferable to start treatment for pinworms a number of days prior to immersing in the mikvah. Nevertheless, as long as you clean the external anal area prior to immersion, any pinworms remaining inside your body are not considered a
chatzitzah. Make sure to also wash your hands well (especially under the fingernails) prior to immersion.