Firstly, you need to understand that there is a maximum and minimum oxidation number.
For metals, the minimum is usually $0$ while the maximum is usually the number of their outermost electrons. For example, $\ce{Na}$ which has $1$ outermost shell electron would have a minimum of $0$ and a maximum of $1$.
For non-metals, the minimum is usually the number of their outermost shell electrons minus $8$, while the maximum is usually the number of their outermost shell electrons. For example, $\ce{S}$ which has 6 outermost shell electrons would have a minimum of $-2$ and a maximum of $6$.
For the pair $\ce{CO2}$ and $\ce{H2C2O4}$:
Firstly, note that the most electronegative element in each compound is $\ce{O}$. You can learn more about electronegativity here.
Therefore, it takes the minimum, which is $-2$.
Secondly, usually hydrogen is $1$ (in most covalent compounds) or $-1$ (in most ionic compounds). In this case, hydrogen is $1$.
It follows from calculation (that the sum of the electronegativity of each element in a compound must be zero) that the $\ce{C}$ in the first compound has oxidation number $4$ while that in the second compound has oxidation number $3$.
Since the oxidation number has dropped, this is a reduction reaction.
We write the unbalanced equation as a starter:
$$\ce{2CO2 -> H2C2O4}$$
Balancing the number of $\ce{C}$.
Now, we are in an acidic environment, so we add $\ce{H2O}$ to balance the oxygen and $\ce{H+} to balance the hydrogen. The oxygen is already balanced, so:
$$\ce{2H+ + 2CO2 -> H2C2O4}$$
Note that the charges are still not balanced while the elements are balanced, so we add electrons:
$$\ce{2H+ + 2CO2 + 2e- -> H2C2O4}$$
Thus our half equation is complete.
The method to find the oxidation number of each element in $\ce{C6H12O6}$ is detailed above, and I leave this for you as an exercise.
PS: in an alkaline environment, we add $\ce{OH-}$ to both sides of the equation to eliminate the $\ce{H+}$, i.e. (the following is wrong because we are in an acidic environment thanks to the acid $\ce{H2C2O4}$ (acetic acid):
$$\ce{2H+ + 2OH- + 2CO2 + 2e- -> H2C2O4 + 2OH-}$$
$$\ce{2H2O + 2CO2 + 2e- -> H2C2O4 + 2OH-}$$