This paper is devoted to invest an optimal investment strategy for a defined-contribution (DC) pension plan under the Ornstein-Uhlenbeck (O-U) process and the loan. By considering risk-free asset, a risky asset driven by O-U process and a loan in the financial market, we firstly set up the dynamic equation and the asset market model which are instrumental in achieving the expected utility of ultimate wealth at retirement. Secondly, the corresponding Hamilton-Jacobi-Bellman(HJB) equation is derived by means of dynamic programming principle. The explicit expression for the optimal investment strategy is obtained by Legendre transform method. Finally, different parameters are selected to simulate the explicit solution and the financial interpretation of the optimal investment strategy is given.