O is in the 6A column, so it has 6 valence electrons. It has total 8 electrons in its atom.
The first two electrons will be placed in the 1s orbital. 1s can accommodate two electrons the next 2 electrons for O go in the 2s orbital. The remaining four electrons will jump to the 2p orbital.
Therefore, the O electron configuration will be 1s22s22p4.