Annelids are really interesting in this regard because they may reproduce sexually or asexually, depending on the species.
Sexually reproducing earthworms are hermaphroditic, meaning that they have both male and female reproductive parts. But this doesn't mean that they self-fertilize; instead, they meet up, align their bodies in opposite directions, and exchange sperm. This sperm is later collected by a cocoon of mucus that works its way up the outside of the worm's body, which also collects that worm's own eggs, fertilizes them, and then that cocoon ends up in the soil which is where the future worms-to-be develop.
Polychaete and oligochaete species can reproduce both sexually and asexually, while leeches can only reproduce sexually. For sexual reproduction involving the formation and fusion of gametes, polychaete species normally have separate sexes, while most oligochaetes are hermaphrodites. In order to reproduce sexually, marine polychaetes must undergo a major physical transformation known as epitoky.