When facing microbes, animals engage in behaviors that lower the impact of the infection. We previously demonstrated that internal sensing of bacterial peptidoglycan reduces Drosophila female oviposition via NF-κB pathway activation in some neurons (Kurz et al., 2017). Although we showed that the neuromodulator octopamine is implicated, the identity of the involved neurons, as well as the physiological mechanism blocking egg-laying, remained unknown. In this study, we identified few ventral nerve cord and brain octopaminergic neurons expressing an NF-κB pathway component. We functionally demonstrated that NF-κB pathway activation in the brain, but not in the ventral nerve cord octopaminergic neurons, triggers an egg-laying drop in response to infection. Furthermore, we demonstrated via calcium imaging that the activity of these neurons can be directly modulated by peptidoglycan and that these cells do not control other octopamine-dependent behaviors such as female receptivity. This study shows that by sensing peptidoglycan and hence activating NF-κB cascade, a couple of brain neurons modulate a specific octopamine-dependent behavior to adapt female physiology status to their infectious state.