My son asked me how worms reproduce and alas I had no clue.
It turns out it is quite an interesting story, though somewhat disgusting and not all that easy to explain to an eight year old.
https://en.wikipedia.org/wiki/Earthworm#Reproduction
Mating occurs on the surface, most often at night. Earthworms are hermaphrodites; that is, they have both male and female sexual organs. The sexual organs are located in segments 9 to 15. Earthworms have one or two pairs of testes contained within sacs. The two or four pairs of seminal vesicles produce, store and release the sperm via the male pores. Ovaries and oviducts in segment 13 release eggs via female pores on segment 14, while sperm is expelled from segment 15. One or more pairs of spermathecae are present in segments 9 and 10 (depending on the species) which are internal sacs that receive and store sperm from the other worm during copulation. As a result, segment 15 of one worm exudes sperm into segments 9 and 10 with its storage vesicles of its mate. Some species use external spermatophores for sperm transfer.
In Hormogaster samnitica and Hormogaster elisae transcriptome DNA libraries were sequenced and two sex pheromones, Attractin and Temptin, were detected in all tissue samples of both species. Sex pheromones are probably important in earthworms because they live in an environment where chemical signaling may play a crucial role in attracting a partner and in facilitating outcrossing. Outcrossing would provide the benefit of masking the expression of deleterious recessive mutations in progeny.
Copulation and reproduction are separate processes in earthworms. The mating pair overlap front ends ventrally and each exchanges sperm with the other. The clitellum becomes very reddish to pinkish in color. Some time after copulation, long after the worms have separated, the clitellum (behind the spermathecae) secretes material which forms a ring around the worm. The worm then backs out of the ring, and as it does so, it injects its own eggs and the other worm’s sperm into it. As the worm slips out of the ring, the ends of the cocoon seal to form a vaguely lemon-shaped incubator (cocoon) in which the embryonic worms develop. They emerge as small, but fully formed earthworms, but lack their sex structures, which develop in about 60 to 90 days. They attain full size in about one year. Scientists predict that the average lifespan under field conditions is four to eight years, while most garden varieties live only one to two years. Several common earthworm species are mostly parthenogenetic.
Among lumbricid earthworms, parthenogenesis arose from sexual relatives many times. Parthenogenesis in some Aporrectodea trapezoides lineages arose 6.4 to 1.1 million years ago from sexual ancestors.