Stiefel-Whitney class of an orthogonal representation
Put $$A=\{c\in H^2(BG;\mathbb{Z}/2): c = w_2(V) \text{ for some } V\}$$ Here are some observations:
- Let $V$ be a real representation with determinant $L$, so $w_1(V)=w_1(L)$. Put $W=V\oplus L\oplus L\oplus L$. We find that $\det(W)=1$ and $w_2(W)=w_2(V)$. It follows that $A=\{w_2(W):\det(W)=1\}$. Moreover, if $\det(V)=\det(W)=1$ then $w_2(V\oplus W)=w_2(V)+w_2(W)$. It follows that $A$ is a subgroup of $H^2(BG;\mathbb{Z}/2)$.
- If $a,b\in H^1(BG;\mathbb{Z}/2)=\text{Hom}(G,O(1))$ then there are essentially unique one-dimensional representations $L,M$ with $w_1(L)=a$ and $w_1(M)=b$, and this gives $w_2(L\oplus M)=ab$ It follows that $A$ contains all decomposable elements of $H^2(BG;\mathbb{Z}/2)$.
- There is also a well-known isomorphism $H^2(BG;\mathbb{Z})=\text{Hom}(G,S^1)=\text{Hom}(G,SO(2))$. Using this, we see that if $c\in H^2(BG;\mathbb{Z}/2)$ can be lifted to $H^2(BG;\mathbb{Z})$, then it lies in $A$.
- Let $P\colon H^2(X;\mathbb{Z}/2)\to H^m(X;\mathbb{Z}/2)$ be any natural cohomology operation that annihilates $A$ for all $G$. Using point 2 we see that $P$ is zero when $X=B(C_2^2)=(\mathbb{R}P^\infty)^2=K(\mathbb{Z}/2,1)^2$. However, it is a standard fact that the obvious map $$H^*(K(\mathbb{Z}/2,n);\mathbb{Z}/2)\to H^*(B(C_2^n);\mathbb{Z}/2)$$ is injective for all $n$. It follows from this (taking $n=2$) that $P=0$. This means that there are no primary cohomological tests that we can use to determine whether elements lie in $A$.
UPDATE: As Mark Grant points out, one can also treat this as a problem in obstruction theory. It is probably best to organise this in terms of the Atiyah-Hirzebruch spectral sequence $$ \widetilde{H}^p(BG;kO^q) \Longrightarrow \widetilde{kO}^{p+q}(BG), $$ with differentials $$ d_r\colon E_r^{pq} \to E_r^{p+r,q-r+1}. $$ It is a standard fact that \begin{align*} kO^* &= \mathbb{Z}[\eta,\mu,\lambda]/(2\eta,\eta^3,\eta\mu,\mu^2-4\lambda) \\ &= \mathbb{Z}[\lambda]\oplus \mathbb{Z}/2[\lambda]\eta \oplus \mathbb{Z}/2[\lambda]\eta^2\oplus \mathbb{Z}[\lambda]\mu \end{align*} with $|\eta|=-1$ and $|\mu|=-4$ and $|\lambda|=-8$. (In particular, these degrees are all negative, corresponding to the fact that $kO$ is a connective spectrum, so the spectral sequence is concentrated in the fourth quadrant.) A class $c\in H^2(BG;\mathbb{Z}/2)$ gives a class $c\eta^2\in E_2^{2,-2}$. Because we are using the reduced homology version of the spectral sequence we see that $E_r^{pq}=0$ for $p\leq 0$ so all differentials ending at $E_r^{2,-2}$ are zero. The problem is really to understand whether the elements $d_r(c\eta^2)$ are zero or not. Because $kO^{-3}=0$, the first possible differential is $d_3(c\eta^2)\in H^5(BG;\mathbb{Z}).\mu$. The result of Teichner mentioned by Mark must mean that this is $$ d_3(c\eta^2) = \beta Sq^2(c) \mu. $$ As $kO^{-5}=kO^{-6}=kO^{-7}=0$, the next possible differential is $d_7(c\eta^2)$, which lies in $E_7^{9,-8}$, which is a subquotient of $H^9(BG;\mathbb{Z}).\lambda$. One would need quite a bit of detailed information to determine which subquotient. In general we have differentials $d_r(c\eta^2)\in E_r^{2+r,-1-r}$ for $r\in\{3,7,8,9\}\pmod{8}$.
For any particular group $G$ it is probably more efficient to just work out the representation theory and calculate the Stiefel-Whitney classes, but the spectral sequence approach sheds some interesting light on the general picture.
You can set this up as an obstruction theory problem. Your cohomology class is represented by a map $c: BG\to K(\mathbb{Z}/2,2)$, and the question is whether this map lifts through the universal Stiefel-Whitney class $w_2:BO\to K(\mathbb{Z}/2,2)$.
The primary obstruction to such a lift turns out to be the class $$\beta Sq^2(c) = \beta(c\cup c)\in H^5(BG;\mathbb{Z}),$$ where $\beta$ is the Bockstein associated to the coefficient sequence $\mathbb{Z}\to \mathbb{Z}\to \mathbb{Z}/2$. This and several other relevant facts can be found in
Teichner, Peter, 6-dimensional manifolds without totally algebraic homology, Proc. Am. Math. Soc. 123, No.9, 2909-2914 (1995). ZBL0858.57033.
As Neil Strickland mentions, there are higher obstructions which can possibly be defined in terms of secondary cohomology operations, provided you know enough about the Postnikov tower of $BO$.
I don't know of a general criterion, but here are two relevant references.
1) Several statements concerning the relation between the cohomology ring and the subring of Stiefel-Whitney classes are discussed in:
- P. Guillot. The computation of Stiefel-Whitney classes. Annales de l'institut Fourier, Volume 60 (2010) no. 2 , p. 565-606.
The basic punchline seems to be that for most groups, the cohomology ring is generated by Stiefel-Whitney classes of real representations.
2) There is also
- J. Gunarwardena, B. Kahn and C.B. Thomas. Stiefel-Whitney classes of real representations of finite groups. J. Algebra 126 (1989), 327-347.
This paper contains some example calculations. In particular, on pp. 337-338, there is an explicit example group where $H^2$ is not generated by Stiefel-Whitney classes of real representations.
There are some further papers, by Gunarwardena, Kahn, (and probably more that I'm not aware of right now) computing Stiefel-Whitney classes of the regular representation. But again, I don't know of a general criterion. Probably, if you have a specific group, not too large, the methods in the above papers might help deciding the question if all of $H^2$ is generated by Stiefel-Whitney classes.