We show how to apply to Hamiltonian differential systems recent results for studying the periodic orbits of a differential system using the averaging theory. We have chosen two classical integrable Hamiltonian systems, one with the Hooke potential and the other with the Kepler potential, and we study the periodic orbits which bifurcate from the periodic orbits of these integrable systems, first perturbing the Hooke Hamiltonian with a nonautonomous potential, and second perturbing the Kepler problem with an autonomous potential.