In this paper we propose a pension policy that would isolate the social security system from any financial crisis resulting from changes in population structure. This policy consists of linking social security benefits to the fertility behaviour of the individual. We present a theoretical analysis to show that this policy restores the optimality of the capital-labour ratio and the population growth rate in an overlapping-generations model with endogenous fertility. We extend this analysis to the case of heterogeneous agents with respect to their preferences towards children. JEL Code: H55, J13, J18 Key words: pay-as-you-go social security system, overlapping-generations model, endogenous fertility, heterogeneous agents, optimal population growth. # We would like to thank Eduard Berenguer, Maurice Marchand, Philippe Michel, Pierre Pestieau and an anonymous referee for helpful discussion and comments. However we alone are responsible for any errors remaining in the paper. Financial support by Fundacin BBV is gratefully acknowledged by the authors. Corresponding author: Concepci Patxot. 2 1