Solar oxygen abundance is a key parameter for the studies of solar physics. Oxygen abundances of cool stars with different metallicities are important for understanding the galactic chemical evolution. We present non-LTE calculations for O I with the classical plane-parallel (1D) model atmospheres for a set of stellar parameters corresponding to stars of spectral types from A to K. Non-LTE leads to strengthening the O I lines, and the difference between the non-LTE and LTE abundances (non-LTE correction) is negative. The departures from LTE grow toward higher effective temperature and lower surface gravity. In the entire temperature range and log g = 4, the non-LTE correction does not exceed 0.05 dex in absolute value for lines of O I in the visible spectral range. The non-LTE corrections are significantly larger for the infrared O I 7771-5, 8446 Å lines and reach an order of magnitude for A-type stars. To differentiate the effects of inelastic collisions with electrons and neutral hydrogen atoms on the statistical equilibrium (SE) of O I, we derived the oxygen abundance for the five well studied A-type stars. For each star, non-LTE largely removes the difference between the infrared and visible lines found in LTE. In the case of cool stars (Sun and Procyon), inelastic collisions with H I affect the SE of O I, and agreement between the abundances from different lines is achieved when using the Drawin's formalism for collisional rates calculations. The solar mean oxygen abundance from the six lines is ϵ = 8.74 ± 0.05, when using the MAFAGS-OS solar model atmosphere and ϵ = 8.78 ± 0.03, when applying the 3D corrections taken from the literature. The non-LTE abundances of oxygen are derived for the sample of cool dwarfs with various metallicities on high-resolution spectra observed in the Lick observatory.