The question is asking when is the $k$th power map on $\mathbb{Z}_n$ injective. Since $\mathbb{Z}_n$ is finite, this is equivalent to asking when is the map bijective.
If so, then the map must have finite order, so there must be some positive integer $m$ for which $\forall a \in \mathbb{Z} \, a^{k^m} \equiv a \pmod{n}$.
It can be shown that there is an exponent $j \ge 2$ for which $\forall a \in \mathbb{Z}\, a^j \equiv a \pmod{n}$ if and only if $n$ is square-free. Indeed, if $n$ is square-free, then by the Chinese Remainder Theorem, it suffices to check the congruence modulo each prime factor of $n$. Fermat's Little Theorem implies that $a^j \equiv a \pmod{p}$ whenever $p$ is prime and $j \equiv 1 \pmod{p-1}$. From this, it easily follows that the exponent $j$ could be taken to be $\varphi(n)+1$ (or in fact, $\lambda(n)+1$ where $\lambda$ is the Carmichael function). If, on the other hand, $n$ is not square-free (say its prime factorization is $p_1^{e_1}p_2^{e_2}...p_{\omega(n)}^{e_{\omega(n)}}$), then let $a=p_1^{\lceil{e_1/2}\rceil}p_2^{\lceil{e_2/2}\rceil}...p_{\omega(n)}^{\lceil{e_{\omega(n)}/2}\rceil}$. Then, for any $j \ge 2$, $a^j \equiv 0 \not \equiv a \pmod{n}$.
So, if $n$ is not square-free, then the statement holds only for $k=1$. If $n$ is square-free, then the values of $k$ for which the statement holds are exactly those that have a power congruent to $1$ modulo $\lambda(n)$, which are exactly those that are coprime to $\lambda(n)$ (or equivalently, to $\varphi(n)$ since the LCM and product of $p-1$ over the prime factors $p$ of $n$ (which are equal to $\lambda(n)$ and $\varphi(n)$ respectively) have the same distinct prime factors).