The wasp Spalangia endius Walker (Hymenoptera: Pteromalidae) is a major parasitoid of the pupae of fruit flies, which are a common agricultural pest. An understanding of this intricate host-parasitoid interaction could provide basic information necessary for the sustainable integrated biological control of fruit flies. In this study, we investigated the effect of S. endius on different-aged pupae of the melon fly Bactrocera cucurbitae Coquillett by using choice and nonchoice tests under laboratory conditions. We showed that S. endius females oviposited, and their progeny successfully developed, in different-aged pupae of B. cucurbitae regardless of the method of exposure. There was an oviposition preference for 3-5-d-old pupa. The highest mean percentage parasitism occurred on 4- and 5-d-old hosts, followed by 2- and 3-d-old hosts. The average development time for both males and females was significantly longer in 6-7-d-old hosts than in the younger host stages. Adult females that developed from younger host pupae (2-5-d old) were significantly heavier than those from older host pupae (6-7-d old), and they also lived longer. The sex ratio (proportion of females) of the parasite progeny decreased with an increase in host age. Host mortality also decreased gradually as the pupal age increased. The differences in development time, body weight, and longevity between females and males were significant. These results suggest that S. endius is a good candidate for the biological control of B. cucurbitae.