Photoluminescence emission spectroscopy and electrical transport measurements have been employed to study the origin and roles of oxygen impurities in hexagonal boron nitride (h-BN) epilayers grown on sapphire substrates. The temperature dependence of the electrical resistivity revealed the presence of a previously unnoticed impurity level of about 0.6 eV in h-BN epilayers grown at high temperatures. The results suggested that in addition to the common nitrogen vacancy (VN) shallow donors in h-BN, oxygen impurities diffused from sapphire substrates during high temperature growth also act as substitutional donors (ON). The presence of ON gives rise to an additional emission peak in the photoluminescence spectrum, corresponding to a donor-acceptor pair recombination involving the ON donor and the CN (carbon occupying nitrogen site) deep level acceptor. Moreover, due to the presence of ON donors, the majority charge carrier type changed to electrons in epilayers grown at high temperatures, in contrast to typical h-BN epilayers which naturally exhibit "p-type" character. The results provided a more coherent picture for common impurities/defects in h-BN as well as a better understanding of the growth mediated impurities in h-BN epilayers, which will be helpful for finding possible ways to further improve the quality and purity of this emerging material.