Following Tomas's suggestion, I am posting this as an answer:
I encountered this problem while directing a Master's thesis two years ago, and again (in a different setting) with another thesis last year. I seem to recall that I somehow got to this while reading slides of a talk by Paul Pollack. Anyway, I like to deduce the results asked in the problem from quadratic reciprocity: First, $f$ is the identity when $p=3$. From now on, assume $p\ne 3$. It suffices to prove that $p\equiv −1\pmod 3$ iff $f$ is injective. This is clear if $p=2$, so we may assume $p$ is odd. Also, if $x,y\in\mathbb F_p$, $x\ne0$, and $x^3=y^3$, then $\displaystyle\left(\frac xy\right)^3=1$, so it suffices to show that for $p$ odd prime, $x^3=1$ has only one solution iff $p\equiv−1\pmod 3$.
Now, $x^3=1$ if $x=1$ or $x^2+x+1=0$. The second option is equivalent to $(2x+1)^2+3=0$, so there are non-trivial solutions iff $−3$ is a quadratic residue modulo $p$. Now apply quadratic reciprocity:
$$\displaystyle \left(\frac{−3}p\right)=\left(\frac{−1}p\right)\left(\frac 3p\right)=(−1)^{\frac{p−1}2}(−1)^{\frac{p−1}2\cdot\frac{3−1}2}\left(\frac p3\right), $$
and the result follows, since $\displaystyle \left(\frac p3\right)=p\pmod 3$.
By the way, the OP's application to counting the number of solutions of $x^3+y^3=z^3$ is a natural one. For more on the number of solutions of $x^q+y^q=z^q$, this was studied by Dickson in 1909; see lecture 12 in
Paulo Ribenboim. 13 Lectures on Fermat’s Last Theorem, Springer-Verlag, New York-Heidelberg, 1979. MR0551363 (81f:10023).
You may also want to look at Chapter 6 of my student Summer Kisner's thesis, mentioned above, and at the references discussed there.
Let me close by briefly mentioning the setting in which my student Thomas Chartier and I ran into this result while working on his thesis. Tommy was studying a nice problem (still open) that originated on MO, see here. The question is whether, for any $n\in\mathbb Z^+$, there is a coloring of the positive integers such that, for any $a$, the numbers $a,2a,\dots,na$ all receive different colors.
There is an easy such coloring if $n+1$ is prime: Say $n+1=p$. Write $a$ as $kp^t$ where $p$ does not divide $k$, and assign to $a$ the color $k\pmod p$. There is also an easy coloring if $2n+1$ is prime: say $n+1=p$. As before, write $a=kp^t$. Now assign to $a$ the color $k^2\pmod p$.
A generalization is easy: If $nl+1=p$ is prime, and $1^l,2^l,\dots,n^l$ are all distinct modulo $p$, then we assign to $a=kp^t$ the color $k^l\pmod p$. It is the second condition (that $1^l,\dots,n^l$ are distinct modulo $p$) that is hard to verify (and automatic if $l=1$ or $l=2$). In fact, for any $l>2$ there are only finitely many $n$ such that $nl+1$ is prime and the second condition is verified. For $l=3$, there are no such $n$, and the proof of this is essentially the result this question asked about, what one shows is that if $3n+1=p$ is prime, then there is an $i$ with $2<i\le n$ such that $i^3\equiv 1$ or $i^3\equiv 8\pmod p$.
(For this and additional related results, see Chapter 5 of Tommy's thesis, and this MO question.)