Oxidation of an aldehyde - how is this a loss of electrons?
OILRIG always holds, but you need to be careful at what you are actually looking at. When we say a compound gets oxidised, that is technically not true. In this framework, only atoms get oxidised or reduced. 
In the reaction 
$$\ce{R-CHO + [O] -&gt; R-COOH}$$
we usually omit the reduction part, because it's always the same: the oxygen.

To identify the whole redox process, use oxidation numbers. Keep in mind that these are simply a bookkeeping tool and the partial charges of the atoms involved might be quite different. Setting $\ce{R {=} CH3}$ or the above reaction it boils down to this:
$$\ce{
\overset{+1}{H}_3\overset{-3}{C}-\overset{\color{\red}{+1}}{C}\overset{+1}{H}\overset{-2}{O}
+ [\overset{\color{\green}{0}}{O}]
-&gt;
\overset{+1}{H}_3\overset{-3}{C}-\overset{\color{\red}{+3}}{C}\overset{-2}{O}\overset{\color{\green}{-2}}{O}\overset{+1}{H}
}$$

Now you can see that the carbonyl carbon increases its oxidation state from $\color{\red}{+1}$ to $\color{\red}{+3}$, so formally it lost $\pu{\color{\red}{2} e^-}$. The oxidising agaent, indicated with $\ce{[O]}$, at the same time decreases its oxidation state from $\color{\green}{0}$ to $\color{\green}{-2}$, therefore formally gaining $\pu{\color{\green}{2} e^-}$. The redox reaction is complete.

Let's look at a real world example, the Baeyer-Villiger oxidation:



As you can see, the ketone gets oxidised, more precisely the carbonyl carbon gets oxidised as increases its oxidation state. On the other side, the peroxide oxygens get reduced as they decrease their oxidation state.