We analyze second-harmonic generation (SHG) oscillations due to quantum-well states in ultrathin overlayer films and their dependence on the electronic and magnetic structure of the film and substrate. Depending on the SHG contribution from the surface and the film-substrate interface, and the interplay between the wave-function symmetry (via the dipole matrix elements) and band-structure effects, one obtains different SHG oscillations as a function of film thickness. One may obtain only one period, which is twice that observed in the linear magneto-optical Kerr effect ${\ensuremath{\Lambda}}_{M},$ but also ${\ensuremath{\Lambda}}_{M}$ and an additional, larger period. Thus we explain, within a unified approach, recent experiments on $x$-Au/Co(0001)/Au(111) and $x$-Cu/Fe/Cu(001) films, where different characteristic features of the SHG oscillations and different oscillation periods were observed.