This is closely related to this question which in turn has to do with the motivation for gauge invariance.
Making a quick recap to make this question self-contained, in his QFT book, chapter 5, Weinberg argues that when we try to embedd creation and annihilation operators of massless particles with helicity $\pm1$ into a quantum field $A_\mu(x)$ it doen't transform as a vector. Instead it transforms as: $$U_0(\Lambda)A_\mu(x)U_0^{-1}(\Lambda)=\Lambda_\mu ^\nu A_\nu(\Lambda x)+\partial_\mu \Omega(x,\Lambda).$$
Well, this would be a problem at first because Weinberg argues in the same chapter that in order to have a Lorentz invaraint evolution, the Hamiltonian density should actually be built locally out of fields transforming as representations of the Lorentz group. In particular we would really need $$U_0(\Lambda)A_\mu(x)U_0^{-1}(\Lambda)=\Lambda_\mu ^\nu A_\nu(\Lambda x).$$
Now in the EM chapter Weinberg says that: if the total action $I[A,\Psi]$ of the field $A$ interacting with matter fields is invariant under $A\mapsto A+d\epsilon$ when field equations are satisfied then there's no problem and the term $\partial_\mu \Omega$ doesn't matter.
Why is that? I mean one is requiring gauge invariance of the action when equations of motion are satisfied and saying that this implies a Lorentz invariant interaction. But what is the proof of that? Why it even suffices to require this when equations of motion are satisfied?