We study implications of habit formation for optimal taxation. First, we show that taxation problems with habit formation can be analyzed using dynamic programming techniques. Second, we derive optimal labor and savings wedges for habit formation preferences. We show that habit formation counteracts the conventional Mirrleesian distortions and calls for subsidies to labor supply and savings. We demonstrate that the theoretical results are quantitatively important: in a stylized life-cycle model, average labor and savings wedges fall by more than one third compared to time-separable references. Third, we exploit the analogy between habit formation and durable consumption to study the taxation of durable and nondurable commodities.