Pinworms are highly contagious and are primarily spread through the ingestion of pinworm eggs. These eggs can be transferred to the mouth via contaminated hands, food, or surfaces. Children often contract pinworms by touching their mouth after scratching the perianal area.