In OLS we assume that Given the model : $Y|X = F(X) + U|X $ Where U is the residuals ,we then ASSUME $E(U|X) = 0$ in order to have $prediction = F(X) = E(Y|X)$ . So the $E(U|X) = 0$ is an assumption and not a consequence of using OLS , wich means that we could have wrong parameters estimates if the assumption does not hold ( including bias in the parameters )
However It is known that minimizing the MSE in linear regression gives the $E(Y|X)$ as a minima , So we could also say that Given the model : $Y|X = F(X) + U|X $ Where U is the residuals . We search for $F(X)$ such that it minimizes the MSE . and that gives $prediction = F(X) = E(Y|X)$ and so now it becomes a CONSEQUENCE that $E(U|X) = 0$ because of $Y|X = F(X) + U|X $
So the question is this statement : $E(U|X) = 0$ an assumption that we need to guarantee before using OLS or a consequence that OLS guarantees when we use it on the residual ?