Reverse chemical ecology has been widely applied for the functional characterization of olfactory proteins in various arthropods, but few related studies have focused on parasitic wasps. Here, the odorant carrier Niemann–Pick C2 protein of Baryscapus dioryctriae (BdioNPC2b) was studied in vitro and in vivo. Ligand binding analysis revealed that BdioNPC2b most strongly bound to 2-butyl-2-octenal and which compound could elicit an EAG response and attracted B. dioryctriae adults. Moreover, this odorant attractant significantly improved the reproductive efficiency of B. dioryctriae compared to that of the control. Then, the relationship between BdioNPC2b and 2-butyl-2-octenal was validated by RNAi, and site-directed mutagenesis revealed the involvement of three key residues of BdioNPC2b in binding to 2-butyl-2-octenal through hydrogen bonding. Our findings provide not only a deeper understanding of the olfactory function of NPC2 in wasps but also useful information for improving the performance of the parasitoid B. dioryctriae as a biological control agent.