We study the role of firm heterogeneity in affecting business cycle dynamics and optimal stabilization policy. Firms differ in their degree of cyclicality, and hence, exposure to aggregate risk, leading to firm-specific risk premia that influence resource allocations. The heterogeneous firm economy can be recast in a representative firm formulation, but where total factor productivity (TFP) is endogenous and depends on the resource allocation. The model uncovers a novel tradeoff between the long-run level and volatility of TFP. Inefficiencies distort this tradeoff and result in either excessive volatility or depressed output, implying a role for corrective policy. Embedding this mechanism into a workhorse New Keynesian model, we show that allocational considerations can strengthen the incentives for leaning against the wind, i.e., optimal policy is more strongly countercyclical than in an observationally equivalent economy that abstracts from heterogeneity. A quantitative exercise suggests that the losses from ignoring heterogeneity can be substantial, which stem largely from a less productive allocation of resources and so depressed TFP and output.