(E)-β-ocimene is a predominant component of volatile terpenes emitted from many plant species in response to herbivore attack, which plays an impotant role in direct and indirect defense of plants. In the current study, (E)-β-ocimene was induced and released in upland cotton Gossypium hirsutum plants infested by chewing caterpillars or sucking bugs. Using genome data mining, a key terpene synthase for (E)-β-ocimene biosynthesis in cotton, GhTPS16, was initially identified. In vitro, recombinant GhTPS16 catalyzed the formation of (E)-β-ocimene using geranyl diphosphate as a substrate. Besides, the GhTPS16 was transferred into Nicotiana tabacum to generate (E)-β-ocimene synthase overexpression lines. Consequently, compared with wild type plants both GhTPS16 expression and (E)-β-ocimene emission of transgenic plants were up-regulated. In behavioral trials, two parasitoid wasps, Peristenus spretus parasitizing green bug Apolygus lucorum and Microplitis mediator parasitizing cotton bollworm Helicoverpa armigera, showed tendency preference for synthetic (E)-β-ocimene and transgenic tobacco plants, respectively. These findings provide new insights into understanding the roles of (E)-β-ocimene in plant-insect interaction. Oversynthesis of (E)-β-ocimene in plants could enhance indirect defense by recruiting parasitoids to facilitate control of the two target pests, green bug and cotton bollworm.