We present a unified framework designed to provide an optimal investment strategy for members of a defined contribution pension plan. Our model guarantees a minimum retirement savings level, expressed as a target annuity, by assuming uncertainty in interest rates, labor income, and mortality during the accumulation phase. To protect the accumulated retirement capital against both investment and longevity risks, the present value of the guaranteed lifetime annuity is regarded as the baseline wealth to hold upon reaching the retirement date, while a purpose-oriented proportion portfolio strategy is employed to invest the residual wealth. By applying standard dynamic programming techniques, we determine a closed-form solution to the stochastic control problem with the objective of maximizing the expected utility of the final surplus, defined as the difference between the accumulated wealth and the target annuity value. The theoretical findings are bolstered by a comprehensive numerical analysis, designed to assess the impact of longevity on investment policies, highlighting the suitability of our proposal in managing defined contribution schemes.