A method was developed to model and optimize selection on multiple identified quantitative trait loci (QTLs) and polygenic estimated breeding value, in order to maximize a weighted sum of cumulative response to selection over multiple years in a population with overlapping generations. The model allows for a population with multiple sex-age classes, different number of age class between sires and dams, and varied genetic contribution of the age class. The optimization problem was formulated as a multiple-stage optimal control problem and solved by a forward and backward iteration loop. The practical utility of this method was illustrated in an example of pig breeding population with overlapping generations. The selection response of this method was compared with standard QTL selection and conventional best linear unbiased prediction (BLUP) selection. Simulation results show that optimal selection achieved greater selection response than either standard QTL or conventional BLUP selections. The influence of population structure on optimal selection was significant. Optimal QTL selection and standard QTL selection were more favorable in a population with overlapping generations than discrete generations, and obtained more benefits relative to conventional BLUP selection in a population with overlapping generations. Optimal QTL selection relative to conventional BLUP selection is also more favorable following increase of genetic contribution of two-year-old boars and sows in a population with overlapping generations.