You are right that you want to verify that this is a well-defined function. Let $a_b\in A_b$ the chosen element. Then we want to check that $g=\{\langle b,a_b\rangle\mid b\in B\}$ is an injective function from $B$ into $A$.
To see that it is a function, note that if $\langle b,x\rangle$ and $\langle b,y\rangle$ are both in $g$, then by the definition of $g$, $x=a_b$ and $y=a_b$. While our choice was arbitrary, we only chose one element from each $A_b$. Therefore $x=y$ and so $g$ is indeed a function.
The rest, as you note, is quite simple.
It should be noted that (1) the axiom of choice is definitely needed for making these arbitrary choices; (2) depending on how you formulate the axiom of choice, $g$ may just be taken as a choice function for the family $\{A_b\mid b\in B\}$, which you have shown to be a family of non-empty sets; and (3) in either way, this follows from the fact that the axiom of choice (in any of its infinitely many formulations) gives arbitrary choices, but well-defined choices.