Answer:
Oxygen and Carbon are in the non-metal section. Both are in 2nd period while Carbon is in group 4A and Oxygen is in group 6A.
Oxygen has more valence electrons than carbon. I wish I could give you a more accurate explanation why on paper, but all you need to do is count the electrons on the largest shell.
Here's the orbital notation of Carbon: 1s^2 2s^2 2px^1 py^1
Carbon's largest shell is 2. Count the electrons on shell 2, and you get 4 valence electrons.
Orbital notation of Oxygen: 1s^2 2s^2 2px^2 py^1 pz^1
Oxygen's largest shell is 2. So, like with carbon, count the electrons on the largest shell. You get 6.
There is a way easier way of interpreting this where you do not even have to write the orbital notation. I wish I can explain, but just know the periods and the group numbers.