We investigate the electronic properties of monolayer and bilayer MoS2 on alpha-quartz substrate through first-principles density functional calculations. Due to the coupling of the MoS2 with the substrate, the valence band edge state at the Brillouin zone center tends to shift upward, reducing the indirect band gap of the MoS2, whereas the direct gap at the K valleys is less sensitive to substrate conditions. By taking into account the van der Waals interactions between the MoS2 and the substrate, we find that monolayer MoS2 exhibits a transition from direct-gap to indirect-gap semiconductor in the presence of surface O-dangling bonds. Moreover, a charge transfer occurs from MoS2 to SiO2, inducing p-type doping and lifting the Kramers degeneracy by breaking the time reversal symmetry. In bilayer MoS2, O-dangling bonds break the inversion symmetry by inducing dipole fields across the interface and thereby lower the energy band associated with the one layer relative to the other. Although the time reversal symmetry is also broken, its effect on the spin splitting is extremely small in the K valleys so that a strong coupling between the spin and valley degrees of freedom takes place, similar to that found in free-standing monolayer MoS2.