We introduce a model of the diffusion of an epidemic with demographically heterogeneous agents interacting socially on a spatially structured network . Contagion-risk averse agents respond behaviorally to the diffusion of the infections by limiting their social interactions . Firms also respond by allowing employees to work remotely, depending on their productivity . The spatial structure induces local herd immunities along socio-demographic dimensions, which significantly affect the dynamics of infections . We study several non-pharmaceutical interventions; e.g., i) lockdown rules, which set thresholds on the spread of the infection for the closing and reopening of economic activities; and ii) selective lockdowns, which restrict social interactions by location (in the network) and by the demographic characteristics of the agents . Substantiating a"Lucas critique"argument, we assess the cost of naive discretionary policies ignoring agents and firms' behavioral responses.