$\mathrm{GL}_n(K)\to\mathrm{SL}_n(K)$ has a retraction iff the following two conditions hold

 1. The subgroup of $n$-root of unity in $K^*$ has a direct summand in $K^*$.
 2. $x\mapsto x^n$ is surjective on $K$

Let us first check that (1.) is equivalent to the existence of a retraction in restriction to $K^*\mathrm{SL}_n(K)$ (the subgroup generated by homotheties and unimodular matrices). Clearly it implies it (consider the set of scalar matrices whose diagonal entry belongs to this direct summand). Conversely, if there is a retraction, its kernel has trivial intersection with $\mathrm{SL}_n(K)$, hence contained in its centralizer, which is reduced to scalar matrices, so it should form the set of scalar matrices with diagonal entry in some direct summand of the set $n$-roots of unity in $K^*$.

Now it is clear that $K^*\mathrm{SL}_n(K)$ equals $\mathrm{GL}_n(K)$ if and only if (2.) holds; so if both (1.) and (2.) hold it follows that we have a retraction; conversely if we have a retraction, its kernel is a normal subgroup with trivial intersection with $\mathrm{SL}_n(K)$, hence contained in its centralizer, which is reduced to scalar matrices, so $\mathrm{GL}_n(K)$ should be generated by unimodular and scalar matrices, i.e. (2.) holds, and then the first verification shows that (1.) holds.

Edit: as noticed by Julian Rosen, (2.) together with (1.) implies something much stronger than (1.), namely that the subgroup of $n$-roots of unity is actually trivial, which means that $x\mapsto x^n$ is injective on $K$. To conclude:

> $\mathrm{GL}_n(K)\to\mathrm{SL}_n(K)$ has a retraction (in the category of groups) iff $x\mapsto x^n$ is a permutation of $K$