This paper characterizes the optimal policy within a dynamic search model of the labor market with risk-averse workers. In a first-best allocation of resources, unemployment benefits should provide perfect insurance against the unemployment risk, layoff taxes are necessary to induce employers to internalize the cost of dismissing an employee but should not be too high in order to allow a desirable reallocation of workers from low to high productivity jobs, hiring subsidies are needed to partially offset the adverse impact of layoff taxes on job creation and payroll taxes should be approximately equal to zero. I obtain an optimal rate of unemployment which is, in general, different from the output maximizing rate of unemployment. When workers have some bargaining power, which prevents the provision of full insurance, it is optimal to reduce the rate of job creation below the output maximizing level in order to lower wages and increase the level of unemployment benefits. Thus, layoff taxes should typically exceed hiring subsidies which generates enough surplus to nance at least some of the unemployment benets. The inclusion of moral hazard does not change this conclusion, unless workers have low bargaining power.