If $f$ is not one-to-one, then there are distinct $a_1, a_2 \in A$ such that $f(a_1) = f(a_2) \in B$. As a result,
$$ \left| f(A) \right| < |A|.$$
So there must be some $b \in B$ with no preimage. Hence, $f$ is not onto.
For the converse, just run the arguments in reverse.