Whereas studies on the optimal taxation under endogenous longevity assume a fixed heterogeneity of lifestyles, this paper analyses the optimal tax policy in an economy where unequal longevities are the unintended outcome of differences in lifestyles, and where lifestyles are transmitted across generations. For that purpose, we develop a three-period OLG model where the population, who ignores the negative impact of excessive work on longevity, is partitioned in two groups with different tastes for leisure, and follows an adaptation/imitation process à la Bisin and Verdier (2001). The optimal short- and long-run Pigouvian taxes on wages are shown to differ, because the latter correct agents' myopia, but also internalize intergenerational externalities due to the socialization process. The internalization of composition effects raises the Pigouvian tax on the wage of one type of agents, but reduces it on the other type, in such a way as to induce the optimal long-run partition of the population