This was a cute exercise, and one that I don't recall having seen!
I assume that $\operatorname{tr}$ stands for the relative trace sometimes denoted $\operatorname{tr}_{L/K}$. Context will make such abbreviations non-problematic.
You already made the key observations that
- $f$ is $K$-linear, and, as $L$ is finite,
- $f$ is a permutation if and only if it is injective.
In addition to those we need the fact from basic linear algebra that a linear transformation is injective if and only if its kernel is trivial.
You are right in that the element $z:=\operatorname{tr}(ab)$ plays a key role in deciding injectivity of $f$. But, in fact, your hunch is only half correct. If $z=0$, the function $f$ is, indeed, a permutation. But I arrived at the general observation:
The transformation $f$ is a permutation if and only if $z\neq-1$.
A way to see this is the following. Assume that $x\in L$ is in the kernel. From
$f(x)=0$ we arrive at
$$
x=-a\operatorname{tr}(bx).\tag{1}
$$
Observe that here $y:=\operatorname{tr}(bx)\in K$. So $x=-ay$ and
$$
\operatorname{tr}(bx)=\operatorname{tr}(-aby)=-y\operatorname{tr}(ab)=-yz\tag{2}
$$
by $K$-linearity of the trace.
The equations $(1)$ and $(2)$ thus imply that
$$
0=f(x)=f(-ay)=-ay+a\operatorname{tr}(bx)=-ay-ayz=-ay(1+z)=-x(1+z).
$$
So unless $z=-1$ we see that $x=0$ is the only element of the kernel, proving the claim. Of course, if $z=-1$, the above calculation shows that every element of the form $x=-ay$, $y\in K$ is in the kernel of $f$.
A particular case is that of $K=\Bbb{F}_2$ when either $z=0$ or $z=1=-1$. In that setting your original hunch is correct and $f$ is a permutation if and only if $\operatorname{tr}(ab)=0$.