I don't think the original question specified that $G = H \times K$. Without this specification, the answer is quite different (as Mariano indicated in the comments).
Consider $G = D_8 \times Q_8$. Then $H=Z(D_8) \times 1$ and $K=1 \times Z(Q_8)$ are both characteristic subgroups of $G$. The automorphism group of $G$ has order 3072, the automorphism group of $H \times K$ has order 6, and the image of the automorphism group of $G$ inside the automorphism group of $H \times K$ has order 1. In particular, the map $\phi$ from Babak's answer need not be injective or surjective if $G \neq H \times K$.
Let's look at homomorphisms of direct products.
Proposition: There is a correspondence between $\newcommand{\Hom}{\operatorname{Hom}}\Hom( H \times K, G )$ and $\Hom(H,G) \times \Hom(K,G)$ which is injective in general, and bijective if $G$ is abelian.
Proof: Suppose $f:H \times K \to G$ is a homomorphism. it turns out $f$ is also a direct product: $f((h,k)) = f((h,1) \cdot (1,k)) = f((h,1)) \cdot f((1,k))$. Define $f_H : H \to G : h \mapsto f((h,1))$. Since $(h_1,1)\cdot(h_2,1) = (h_1\cdot h_2,1)$ we get $f_H( h_1 \cdot h_2) = f_H(h_1) \cdot f_H(h_2)$ so $f_H$ is also a homomorphism. Similarly $f_K$ is a homomorphism.
Conversely, suppose we have homomorphisms $f_H : H \to G$ and $f_K : K \to G$ and $G$ is abelian, define $f: H \times K \to G : (h,k) \mapsto ( f_H(h), f_K(k) )$. Since $(h_1,k_1) \cdot (h_2,k_2) = ( h_1\cdot h_2, k_1 \cdot k_2)$ one has $f((h_1,k_1) \cdot(h_2,k_2)) = f((h_1,k_1)) \cdot f((h_2,k_2))$ and $f$ is also a homomorphism.
In summary: the correspondence takes $f$ to $(f_H,f_K)$ as in the first paragraph, and takes $(f_H,f_K)$ to $f$ as in the second paragraph as long as $G$ is abelian. $\square$
Proposition: There is a 1-1 correspondence between $\Hom(G,H \times K)$ and $\Hom(G,H) \times \Hom(G,K)$.
Proof: If $f:G \to H \times K$ is a homomorphism, define $f^H:G \to H:g\mapsto h$ and $f^K:G \to K: g \mapsto k$ where $f(g) = (h,k)$. It is not hard to show $f^H$ and $f^K$ are homomorphisms.
Conversely, if $f^H:G \to H$ and $f^K:G \to K$ are homomorphisms, then define $f:G \to H \times K : g \mapsto (f^H(g), f^K(g))$. It is not hard to show $f$ is a homomorphism.
In summary, the 1-1 correspondence takes $f$ to $(f^H,f^K)$ as in the first paragraph, and takes $(f^H,f^K)$ to $f$ as in the second paragraph. $\square$
Combining these we can handle the case where both the domain and range are direct products. Note that $(f^H)_K = (f_K)^H$ so I just write $f^H_K$.
Proposition: There is a correspondance between $\Hom(H \times K)$ and $\Hom(H,H) \times \Hom(H,K) \times \Hom(K,H) \times \Hom(K,K)$ that is injective in general, and bijective if $H,K$ are abelian.
Proof: $f \mapsto (f^H_H, f^K_H, f^H_K, f^K_K)$. The reverse direction holds if $H,K$ are abelian. $\square$
Now automorphisms are more complicated in general, but if $H$ and $K$ are reasonable independent (contain no isomorphic direct factors), then one has a nice expression given in Arturo's answer.
However, if $\Hom(H,K) = \Hom(K,H) = 0$, then we have diagonal matrices and automorphisms are easy to understand.