The coupling of submonolayer coverages of Fe-phthalocyanine molecules on bare and oxygen-covered ferromagnetic Co(001) films was studied by x-ray-absorption spectroscopy, especially the x-ray magnetic circular dichroism, in combination with density functional theory. We observe that the magnetic moments of the paramagnetic molecules are aligned even at room temperature, resulting from a magnetic coupling to the substrate. While the magnetization of the Fe ions directly adsorbed on the Co surface is parallel to the magnetization of the Co film, the introduction of an oxygen interlayer leads to an antiparallel alignment. As confirmed by theory, the coupling strength is larger for the system FePc/Co than for FePc/O/Co, causing a stronger temperature dependence of the Fe magnetization for the latter system. Furthermore, the calculations reveal that the coupling mechanism changes due to the O layer from mostly direct exchange to Co of the bare surface to a 180 degrees antiferromagnetic superexchange via the O atoms. Finally, by comparing the experimental x-ray-absorption spectra at the N K edge with the corresponding calculations, the contribution of the individual orbitals has been determined and the two inequivalent N atoms of the molecules could be distinguished.