Sex differences in behavior allow animals to effectively mate and reproduce. However, the mechanism by which biological sex regulates behavioral states, which underlie the regulation of sex-shared behaviors, such as locomotion, is largely unknown. In this study, we studied sex differences in the behavioral states of Caenorhabditis elegans and found that males spend less time in a low locomotor activity state than hermaphrodites and that dopamine generates this sex difference. In males, dopamine reduces the low activity state by acting in the same pathway as polycystic kidney disease-related genes that function in male-specific neurons. In hermaphrodites, dopamine increases the low activity state by suppression of octopamine signaling in the sex-shared SIA neurons, which have reduced responsiveness to octopamine in males. Furthermore, dopamine promotes exploration both inside and outside of bacterial lawn (the food source) in males and suppresses it in hermaphrodites. These results demonstrate that sexually dimorphic signaling allows the same neuromodulator to promote adaptive behavior for each sex.