First I will prove that: $$n \in \{2,4\} \pmod{6}$$ is a necessary condition:
Just substitute x for the value 2 so that the equation results:
$$7 | 3 ^ n + 2 ^ n + 1$$
$$3 ^ n + 2 ^ n + 1 \equiv 0 \pmod{7}$$
whose all solutions are:
$$n \in \{2,4\} \pmod{6}$$
Now I am going to prove that these two conditions are sufficient:
As mentioned above:
$$ P = x^2+x+1 $$
$$(x + 1) ^ 6 \equiv 1 \pmod{P}$$
$$x ^ 6 = 1 \pmod{P}$$
If $n \equiv 2 \pmod {6}$:
$$(x + 1) ^ {6a+2} + x ^ {6a+2} + 1 \pmod{P}$$
$$(x + 1) ^ {6a} (x ^ 2 + 2x + 1) + x ^ {6a} x ^ 2 + 1 \pmod{P}$$
$$(P + x) + x ^ 2 + 1 \pmod{P}$$
$$P + x + x ^ 2 +1 \pmod{P}$$
$$2P \pmod{P}$$
$$ 0 \pmod{P} $$
With which is a sufficient condition.
If $n \equiv 4 \pmod {6}$:
$$(x + 1) ^ {6a+4} + x ^ {6a+4} + 1 \pmod{P}$$
$$(x + 1) ^ {6a} (x ^ 4 + 4x ^ 3 + 6x ^ 2 + 4x + 1) + x ^ {6a} x ^ 4 + 1 \pmod{P}$$
$$(x ^ 4 + 4x ^ 3 + 6x ^ 2 + 4x + 1) + x ^ 4 + 1 \pmod{P}$$
$$2x^4 +4x^3+6x ^ 2 + 4x + 2 \pmod{P}$$
$$2(x^2+x+1)^2 \pmod{P}$$
$$ 0 \pmod{P} $$
With which is a sufficient condition.
It is proved that the condition is necessary and sufficient.