The volatile organic compounds (VOCs) of plant hosts allow insect localization through olfactory recognition. In this study, the oviposition behavior of the codling moth was investigated and the VOCs from different walnut organs were extracted and analyzed to systematically study their composition and content differences. The electrophysiological and behavioral responses of the codling moth to walnut VOCs were measured using gas chromatography–electroantennographic detection (GC-EAD) and a four-arm olfactometer to screen the key active contents. The field investigation results indicated that 90.3% of the eggs spawned by the first generation of adult codling moths were adjacent to the walnut fruits. Walnut VOCs are mainly composed of terpenes, aromatics, and alkanes. Twelve VOCs can produce electroantennogenic (EAG) responses in the codling moths. Both adult males and females exhibit concentration dependence, with notable disparities in their EAG response levels. In the olfactory behavioral bioassay, linalool, eucalyptol, and high doses of geranyl acetate showed repellent effects on the codling moths, while myrcene, β-ocimene, nonanal, methyl salicylate, α-farnesene, and heptaldehyde showed the opposite. The relative levels of heptaldehyde, geranyl acetate, nonanal, and methyl salicylate were high in the fruits, which is intimately related to the localization of the walnut fruit by females. These VOCs can influence the oviposition behavior of codling moths but their application in the control of this pest needs to be confirmed and improved through further field experiments.