Let $\{c_i\}$ denote a set of generators of the free abelian $C$. To define $\phi:C \to B$, it suffices to define $\phi$ over the elements $c_i$, then extend this to a homomorphism over all of $C$ by "linearity". In particular, we define
$\phi(c_i)$ is such that $g(\phi(c_i)) = c_i$. This property extends to all of $C$, which is to say that $g(\phi(c)) = c$ for any $c \in C$.
We then define
$$
h(a,c_i) = f(a) + \phi(c_i)
$$
Note: we can guarantee that the conditions on $\phi$ define a homomorphism since $C$ is a free abelian group.
For injectivity: suppose that $h(a,c) = 0$. Then
$$
f(a) + \phi(c) = 0 \implies f(a) = -\phi(c)
$$
However, $f(a)$ is in the kernel of $g$. Thus, applying $g$ to both sides produces $0 = -g(\phi(c)) = c$. That is, $c = 0$. Thus, $h(a,c) = f(a) + \phi(0) = f(a)$, and so $f(a) = 0$. But, $f$ is injective, so $a = 0$.
Surjectivity: note that $g$ induces an isomorphism $\tilde g:B/\ker g \to C$. Thus, for every $b \in B$, there exists a $c \in C$ such that
$$
\tilde g(b + \ker(g)) = c \implies \tilde g(b+\ker g) = \tilde g(\phi(c) + \ker g) \implies\\
b - \phi(c) \in \ker(g)
$$
However, $\ker(g) = im(f)$. So, there exists an $a$ such that $b - \phi(c) = f(a)$. That is,
$$
b = f(a) + \phi(c) = h(a,c)
$$