Any element of $H^1(M,\mathbb{Z}/2)$ is the $w\_1(E)$ of a real line bundle $E$ over $M$. 
I wonder how to characterize (probably using the Steenrod squares) which elements of $H^2(M,\mathbb{Z}/2)$ are the $w\_2(E)$ of a real vector bundle $E$ over $M$. 


Considering tensor products and tensoring by line bundles, it is clear that such elements form a subgroup of $H^2(M,\mathbb{Z}/2)$. I know that any element killed by $Sq^1$ is realizable this way, since if $Sq^1 v=0$ for $v\in H^2(M,\mathbb{Z}/2)$ then $v$ is a reduction of an element $c$ in $H^2(M,\mathbb{C})$. Then one can pick a complex line bundle whose $c\_1$ is $c$, which always exists...



Which elements of $H^2(M,\mathbb{Z}/2)$ are the $w_2(E)$ for a real bundle $E$?
This is an obstruction theory problem; you regard $v\in H^2(M;\mathbb{Z}/2)$ as a homotopy class of maps $v: M\to K(\mathbb{Z}/2,2)$, then ask if $v$ lifts through the universal Stiefel-Whitney class $w\_2:BSO\to K(\mathbb{Z}/2,2)$. The first obstruction is $\beta(v^2)\in H^5(M;\mathbb{Z})$, as mentioned by Theo Johnson-Freyd in the comments, coming from the fact that $w\_2^2(E)$ is the mod $2$ reduction of $p\_1(E)$ for any real vector bundle $E$. The secondary obstruction is more subtle (it will have indeterminacy given by a choice of integral lift of $v^2$, for example) but I would be surprised if there is no information on it in the literature.


I think the state of the art on this question might still be Teichner's paper


*Teichner, Peter*, [**6-dimensional manifolds without totally algebraic homology**](http://dx.doi.org/10.2307/2160595), Proc. Am. Math. Soc. 123, No. 9, 2909-2914 (1995). [ZBL0858.57033](https://zbmath.org/?q=an:0858.57033).


Teichner shows that if $\operatorname{dim}(M)\le 5$, then $\beta(v^2)$ is the only obstruction to $v$ being $w\_2(E)$ for some real vector bundle $E$. On the other hand, he constructs examples of manifolds in all dimensions $n\ge 6$ with classes $v\in H^2(M;\mathbb{Z}/2)$ such that $\beta(v^2)\neq 0$. He also shows that any $v\in H^2(M;\mathbb{Z}/2)$ which is Poincaré dual to a codimension $2$ submanifold $N\subseteq M$ is $w\_2(E)$ for some $E$.


An older paper which also seems relevant is 


*Suzuki, H.*, [**On the realization of the Stiefel-Whitney characteristic classes by submanifolds**](http://dx.doi.org/10.2748/tmj/1178244748), Tohoku Math. J., II. Ser. 10, 91-115 (1958). [ZBL0107.17001](https://zbmath.org/?q=an:0107.17001). 


