We study optimal tax policies in a life-cycle economy with risky human capital and permanent ability differences, where both ability and learning effort are private information of the agents. The optimal policies balance several goals: redistribution across agents, insurance against human capital shocks, incentives to accumulate human capital, and incentives to work. We show that, in the optimum, i) if utility is separable in labor and learning effort, the inverse marginal labor income tax rate follows a random walk, ii) the "no distortion at the top" result does not apply if discouraging labor supply increases incentives to invest in human capital, and iii) quantitatively, high-ability agents face very risky consumption in order to elicit learning effort while low-ability agents are insured. We also find large welfare gains for the U.S. from switching to an optimal tax system. J.E.L. Codes: E6, H2