In many western economies, the phenomenon of ageing population implies that the large Pay-As-You-Go (PAYGO) social security system will run into several severe financial difficulties. In that direction, this paper constructs a discrete-time stochastic model for a quasi PAYGO social security system to allow the potential accumulation of a special (contingency) fund, which can oscillate so as to absorb fluctuations in the various system parameters involved. The basic difference equation is analytically designed including several control variables (i.e. different investment strategies, contribution rates, ages of eligibility for normal retirement and levels of pension benefits). The theoretical model is solved using standard linearization and stochastic optimization techniques resulting in analytic formulae for the control variables. These solutions are actually feedback mechanisms of the past fund values. Finally, we present a practical application for the projected population of Greece for the years 2007-2030 deriving a smooth solution for the development of the controls.