We prove that there exist periodic orbits on almost all compact regular energy levels of a Hamiltonian function defined on a twisted cotangent bundle over the two-sphere. As a corollary, given any Riemannian two-sphere and a magnetic field on it, there exists a closed magnetic geodesic for almost all kinetic energy levels.