I am going to write a community wiki answer here which people can vote up. (See this meta thread concerning the Mathoverflow user, which bumps questions with no voted-up answer.)
Main result: A homomorphism $f: \mathbb Z \to GL_n(\mathbb Q_p)$ extends continuously to $\hat{\mathbb Z}$ if and only if the image of $f$ can be conjugated into $GL_n(\mathbb Z_p)$.
Proof: If $f:\hat{\mathbb Z} \to GL_n(\mathbb Q_p)$ is continuous, the image is compact, hence contained in a maximal compact subgroup, which can be conjugated into $GL_n(\mathbb Z_p)$.
Conversely, if $f:\mathbb Z \to GL_n(\mathbb Q_p)$ lands in a compact subgroup, then the closure of the image is compact, hence profinite (any compact subgroup of $GL_n(\mathbb Q_p)$ is profinite), and hence $f$ extends to $\hat{\mathbb Z}$ (since $\hat{\mathbb Z}$ is precisely the profinite completion of $\mathbb Z$Z$). QED
As noted in the comments, to tell if a matrix (e.g. $f(1)$) can be conjugated into $GL_n(\mathbb Z_p)$, one simply has to look at the characteristic polynomial, and ask that all the coefficients lie in $\mathbb Z_p$, with the constant term being a unit. Thus to apply the theorem in practice, one simply computes the characteristic polynomial of $f(1)$ and see if its satisfies these conditions.
EDIT: Now actually made community wiki; sorry about that --- I thought I had already clicked the CW box, but obviously not. (The point is that the above argument is just a rephrasing of what is in the comments.)

