In this paper, we derive a linear-quadratic model for monetary policy analysis that is consistent with sticky prices and search and matching frictions in the labor market. We show that the second-order approximation to the welfare of the representative agent depends on inflation and "gaps" that involve current and lagged unemployment. Our approximation makes explicit how the costs of fluctuations are generated by the presence of search frictions. These costs are distinct from the costs associated with relative price dispersion and fluctuations in consumption that appear in standard new Keynesian models. We use the model to analyze optimal monetary policy under commitment and discretion and to show that the structural characteristics of the labor market have important implications for optimal policy.