What is the best macroprudential regulation when households differ in their exposure to profits from the financial sector? To answer the question, I study a real business cycle model with household heterogeneity and market incompleteness. In the model, shocks are amplified in states with high leverage, leading to lower investment. I consider the problem of a Ramsey planner who can finance transfers with a distortive tax on labor and levy taxes on the balance sheet components of experts. I show that the optimal tax on capital purchases is zero and the optimal policy relies mostly on a tax on deposit issuance. The latter redistributes between agents by affecting the equilibrium rate on deposits. The welfare gains from optimal policy are due to both redistribution and insurance and are larger the more unequal the initial distribution is. A simple tax rule that targets a level of leverage can achieve most of the welfare gains from optimal policy.