We address the problem of ﬁnding the optimal lockdown and reopening policy during a pandemic like COVID-19, for a social planner who prioritizes health over short-term wealth accumulation. Agents are connected through a fuzzy network of contacts, and the planner’s objective is to determine the policy that contains the spread of infection below a tolerable incidence level, and that maximizes the present discounted value of real income, in that order of priority. We show theoretically that the planner’s problem has a unique solution. The optimal policy depends both on the conﬁguration of the contact network and the tolerated infection incidence. Using simulations, we apply these theoretical ﬁndings to: (i) quantify the tradeoﬀ between the economic cost of the pandemic and the infection incidence allowed by the social planner, and show how this tradeoﬀ depends on network conﬁguration; (ii) understand the correlation between diﬀerent measures of network centrality and individual lockdown probability, and derive implications for the optimal design of surveys on social distancing behavior and network structure; and (iii) analyze how segregation induces diﬀerential health and economic dynamics in minority and majority populations, also illustrating the crucial role of patient zero in these dynamics.