Quadratic optimization is the classical approach to optimal control of pension funds. Usually the payment stream is approximated by a diffusion process. Here we obtain semiexplicit solutions for quadratic optimization in the case where the payment process is driven by a finite state Markov chain model commonly used in life insurance mathematics. The optimal payments are affine in the surplus with state dependent coefficients. Also constraints on payments and surplus are studied.