$\because$ this is a Biconditional proof , we'd have to proof both ways.
1.First, let us prove f is one-to-one $\Rightarrow$ f is onto.
Assume f is not an onto function,$\Rightarrow \exists$ a value in the range which does not have an incoming edge from the domain, but $\because$ |A|=|B|, this cannot happen. $\Rightarrow$ f is onto.
2.1.Now, let us prove f is onto $\Rightarrow$ f is one-to-one .
Assume f is not one-to-one, then |B|<|A|, but we know |A|=|B|, Hence our assumption is false. Therefore f is one-one.
$\therefore$ f is one-to-one $\Leftrightarrow$ f is onto.