The influence of residual gases in an rf sputtering chamber on the magnetic proprties of Co sputtered films is investigated by nuclear magnetic resonance of 59Co nuclei. The surfaces of the prepared Co sputtered films are oxidized. In the films the nitrogen gas is combined with Co atoms and forms the Co4N phase. The broad line width of resonance signals and the slow decrease of signal intensity with the external magnetic fileld suggest that the Co oxides and the Co4N have large effects on the structure of magnetic domains and walls. Under the different gas-flow conditions, the formation of the Co4N phase and the structural change of Co from the hcp phase into the fcc phase can be observed by the apperance of satellite lines and the shift of the main line of spin echo spectra. It is found that the nuclear magnetic resonance is a powerful means for the study of magnetic properties and phase change on the Co sputtered films.