From Wikipedia:
Life Cycle
After mating, the females migrate from the cecum to the rectum, where they emerge from the anus and lay eggs on the skin around the anus.[11] After the eggs have been ingested, the larvae develop to adults in the intestine.[11] The entire life cycle is complete within 4 to 6 weeks, with 30 days being the best estimate.
Reproduction
Pinworms mate by traumatic insemination. After mating, the male dies. The female migrates to the anus and emerges, usually during the night, to deposit about 10,000 to 20,000 eggs in the perianal area (around the anus). She then secretes a substance which causes a very strong itching sensation, inciting the host to scratch the area and thus transfer some of the eggs to the fingers. Eggs can also be transferred to cloth, toys, and the bathtub. Once ingested orally, the larvae hatch in the small intestine, specifically the duodenum, and migrate back to the large intestine where they mature. Maturity is reached in 3045 days. The eggs can survive for 2 to 3 weeks on their own outside of the human body. In some cases, the larvae will hatch in the peri-anal area and travel back inside the anus, up the rectum, and back into the intestines where they mature.[15]