This paper studies the implications of unemployment for the optimal design of the tax-benefit system. To do so, I develop a directed search model where individuals face heterogeneous and uninsurable unemployment risk. They differ in terms of their skills and participation costs and supply labor on the intensive and extensive margin. Matching frictions give rise to a trade-off for workers between high wages and low unemployment risk. The government affects this trade-off by altering the costs and benefits of searching. The associated changes in unemployment generate fiscal externalities which modify optimal tax formulas. How unemployment affects optimal tax policy depends on the elasticity of unemployment with respect to the marginal and average tax rate and on the hazard rate of the income distribution. I show that optimal employment subsidies (such as the EITC) phase in with income. Moreover, financing unemployment benefits through lump-sum or proportional taxes on labor income – as is commonly assumed in the literature – is sub-optimal even in the absence of a motive for redistribution. I calibrate the model to the US economy and find that unemployment is an important margin to consider when setting tax rates at low levels of income. In my preferred calibration, unemployment generates a negative fiscal externality which lowers the mechanical revenue gain of income taxes by 3%.