Food and reproduction are the fundamental needs for all animals. However, the neural mechanisms that orchestrate nutrient intake and sexual behaviors are not well understood. Here, we find that sugar feeding immediately suppresses sexual drive of male Drosophila, a regulation mediated by insulin that acts on insulin receptors on the courtship-promoting P1 neurons. The same pathway was co-opted by anaphrodisiac pheromones to suppress sexual hyperactivity to suboptimal mates. Activated by repulsive pheromones, male-specific PPK23 neurons on the leg tarsus release crustacean cardioactive peptide (CCAP) that acts on CCAP receptor on the insulin-producing cells in the brain to trigger insulin release, which then inhibits P1 neurons. Our results reveal how male flies avoid promiscuity by balancing the weight between aphrodisiac and anaphrodisiac inputs from multiple peripheral sensory pathways and nutritional states. Such a regulation enables male animals to make an appropriate mating decision under fluctuating feeding conditions.