The life cycle of the codling moth is interesting. The inseminated female moth looks for immature fruit and lays eggs on the surface. An egg hatches and the larva goes into the fruit. They are after the developing seed more than the flesh, as they need the fats and proteins, but their sense of direction is poor and they meander around a bit, eating and excreting as they go.
When they've finished eating (and shitting) in your fruit, they crawl out and head down the trunk of the tree. They need to get to the ground and burrow into the soil to pupate. If they are successful in this journey, a new adult moth will come out of the ground in a few weeks and your fruit will get hit a second time. Some areas get three waves of codling moths through the growing season, but two is also common. In the autumn the pupa will hunker down and stay dormant to emerge in late spring or early summer when new fruit is forming. Apples and pears are the familiar targets but they also really like walnuts.
The crawl-down stage is where we can mess with them. If you plant something pungent around the base of the tree, they are either repelled or confused by the aroma and stay on the tree and die. We're using peppermint pelargonium (geranium),
Pelargonium tomentosum, for this purpose, and it seems to be helping. It also has the advantage of forming a nice mat around the trunk and outcompeting weeds and grasses once it's established. And it smells awesome -- minty fresh. I suspect other smelly herbs could also do the trick, but this one works well in our climate so we roll with it.
Pelargonium tomentosum im Botanischen Garten Dresden, Michael Wolf
CC-by-SA