Many behavioural states are modulated by food availability and nutritional status. Here, we report that in Caenorhabditis elegans, the presence of an external food source enhances avoidance responses to soluble repellents sensed by the polymodal ASH neurons. This enhancement requires dopamine signalling and is mimicked by exogenous dopamine. Food modulation is dependent on the mechanosensory cilia of the dopaminergic neurons, indicating that dopamine is released in response to sensation of bacteria. Activation of the dopamine neurons leads within seconds to a transient state of increased sensory acuity. In vivo imaging experiments indicate that this dopamine-dependent sensitization results in part from modality-specific increases in the magnitude and duration of gustatory responses in the ASH neurons. The D1-like dopamine receptor DOP-4 acts cell autonomously in ASH to mediate effects on response magnitude. Thus, dopamine functions as a direct signal of the presence of food to control context-dependent behavioural states.