This is a generalization of the problem below (first appeared here)
I am particularly curious to know if there is a closed-form formula to calculate the probability for any $n$ and any probability of heads $p$.
note: One doesn't need to calculate the probability to show that it is not 50-50. If $n=3$, the exact probability can be calculated with few computational steps. For larger $n$, relatively simple algorithms can be used to calculate the probability; some are more efficient than others.

The teacher is incorrect.
It turns out that there are $220$ cases (out of $2^{10}=1024$) where only one student steps forward because both neighbours flipped heads, and in $60$ of those cases the student stepping forwards also flipped heads. So the probability is $\frac3{11}\approx 27.3\%$
The reason that heads is biased against is that if that student flipped heads then neither of the people two away can also have flipped heads, as otherwise somebody else would also have stepped forward.
To illustrate the point, consider when only the third student steps forward (the second and fourth students must have flipped heads and the sixth and tenth must have flipped tails). In the following $6$ cases the third student could have flipped heads
and in the similar $6$ cases the third student could have flipped tails
though in all those cases the first and fifth students flipped tails. But there are another $10$ cases where the first or fifth flipped heads so the third must have flipped tails, and this demonstrates the bias
Added The answer above deals with the case where only one student has two neighbours both with heads and so the answer is conditional on that position. Others have suggested that the question is different and that if there is more than one student with suitable neighbours then one of those steps forward, presumably randomly from those. Similar
In that case (now conditioned on there being at least one pair of suitable neighbours) there is still a bias towards tails for the student stepping forward. The calculations are now
A weighted average (ignoring $0$ or $9$ suitable pairs of neighbours as nobody will step forward) gives an overall probability that the student stepping forward has heads of $\frac{10763}{25284} \approx 42.6\%$, so the teacher is still wrong.