We consider a stochastic model for a defined-contribution pension fund in continuous time. In particular, we focus on the portfolio problem of a fund manager who wants to maximize the expected utility of his terminal wealth in a complete financial market with stochastic interest rate. The fund manager must cope with two background risks : the salary risk and the inflation risk. We find a closed form solution for the asset allocation problem and so we are able to analyse in detail the behaviour of the optimal portfolio with respect to salary and inflation. Finally, a numerical smulation is presented.