Oxygen exist as a diatomic molecule (O2) as it forms one pσ−pσ bond by axial overlap of two p-orbitals & one pπ−pπ bond by lateral overlap of two p-orbitals due to its small atomic size.
So due to this, the Van der Waals Forces acting on the O2 is very less. So oxygen exist in gaseous state at room temperature.
On the other hand, sulphur doesn't exist as diatomic molecule as it can only form pσ−pσ bond & not pπ−pπ as lateral overlap is not possible because of large atomic size of sulphur atom. So instead, sulphur exist as octatomic molecule (S8). Now since sulphur molecule is made up of 8 sulphur atoms, the Van der Waals Forces acting on S8 is comparitively higher. So S8 molecules are much closely packed compared to O2molecules.
So, Oxygen exist as gas whereas sulphur exist as solid.