Oxygen occurs as O2 molecule due to pπ-pπ bonding because of which the inter-molecular forces in it are weak van der Waals forces as it is small in size with high electron density which tend to repel the other O2 molecules. As a result it exists as gas.
On the other hand, sulphur does not form strong S=S double bonds hence exists as S8 held together by strong covalent bonds and exists as a polyatomic molecule, in which inter-molecular forces are strong so, it exists as a solid.