We develop the variation-perturbation approach for periodic time-dependent perturbations within the Kohn-Sham method of density-functional theory. Our formulation parallels a similar formulation developed by Gonze for static perturbations. The theory is demonstrated by calculating the dynamic polarizability and hyperpolarizability for the helium atom.