Let $S(\Phi,U,K,K_{U})$ denote the solution of the master equation $(S,S)=0$, where $\{\Phi ^{A},U\}$ are the fields and $\{K_{A},K_{U}\}$ are the sources coupled to the $\Phi ^{A}$- and $U$-gauge transformations. If we replace $U$ with the solution $U^{*}(\Phi ,K,K_{U})$ of the $U$-field equations
\begin{equation}
\frac{\delta _{r}S}{\delta U}=0,
\end{equation}
then the action
\begin{equation}
S^{*}(\Phi ,K,K_{U})=S(\Phi ,U^{*}(\Phi ,K,K_{U}),K,K_{U})
\end{equation}
satisfies the master equation $(S^{*},S^{*})=0$ in the reduced set of fields and sources $\Phi,K$.
Proof
Every time we differentiate $S^{*}$ with respect to $\vartheta =\Phi, K$ we must pay attention to the fact that now $U$ depends on $\vartheta $. However, the operation of setting $U=U^{*}$ and the differentiation with respect to $\vartheta $ can be freely interchanged on $S^{*}$, because
\begin{eqnarray*}
\frac{\delta _{r}S^{*}}{\delta \vartheta }&=&\frac{\delta _{r}}{\delta
\vartheta }\left( \left. S\right| _{U=U^{*}}\right) \\&=&\left. \frac{\delta
_{r}S}{\delta \vartheta }\right| _{U=U^{*}}+\int \mathrm{d}^{D}x\left. \frac{%
\delta _{r}S}{\delta U(x)}\right| _{U=U^{*}}\frac{\delta _{r}U^{*}(x)}{%
\delta \vartheta }=\left. \frac{\delta _{r}S}{\delta \vartheta }\right|
_{U=U^{*}}.
\end{eqnarray*}
Setting $U=U^{*}$ inside $(S,S)=0$ and using the identities just found we get precisely $(S^{*},S^{*})=0$. $\Box$
This theorem is a well-known result. Among its applications we mention the case where $U$ are auxiliary fields. Then replacing $U=U^{*}$ inside a local action $S$ produces another local action $S^{*}$. Moreover, that replacement is equivalent to do the functional integral over $U$ (at least using the dimensional-regularization technique).
For example, integrating out auxiliary fields in gauge algebras that close off-shell, such as the one off-shell N=1 supergravity, we obtain gauge algebras that close only on-shell, e.g. the one of on-shell N=1 supergravity. In that case it is well-known that the action $S^{*}$ still solves the master equation, if $S$ does.
An explicit example
In pure non-Abelian Yang-Mills theory the integrated fields are $\{A_{\mu }^{a},C^{a},\bar{C}^{a},B^{a}\}$ and their sources are $\{K_{a}^{\mu },K_{C}^{a},K_{\bar{C}}^{a},K_{B}^{a}\}$. In the Euclidean notation the gauge-fixed action
\begin{eqnarray*}
S &=&\int \left( \frac{1}{4}F_{\mu \nu }^{a\ 2}-\frac{\lambda }{2}%
(B^{a})^{2}+B^{a}\partial \cdot A^{a}-\bar{C}^{a}\partial _{\mu }D_{\mu
}C^{a}\right) \\
&&-\int D_{\mu }C^{a}K_{\mu }^{a}+\frac{g}{2}\int
f^{abc}C^{b}C^{c}K_{C}^{a}-\int B^{a}K_{\bar{C}}^{a}{,}
\end{eqnarray*}
satisfies the master equation $(S,S)=0$, where $D_{\mu }C^{a}=\partial _{\mu}C^{a}+gf^{abc}A_{\mu }^{b}C^{c}$ is the covariant derivative of the ghosts, $f^{abc}$ are the structure constants of the Lie algebra and $F_{\mu \nu }^{a}=\partial_{\mu }A_{\nu }^{a}-\partial _{\nu }A_{\mu }^{a}+gf^{abc}A_{\mu }^{b}A_{\nu}^{c}$ is the field strength. The Lagrange multiplier $B^{a}$ satisfies the assumptions of the theorem. Integrating it out is equivalent to set
\begin{equation}
B^{a}=\frac{1}{\lambda }\left( \partial \cdot A^{a}-K_{\bar{C}}^{a}\right)
\end{equation}
in the action. Thus, defining $\Phi ^{A}=(A_{\mu }^{a},C^{a},\bar{C}^{a})$, $K_{A}=(K_{a}^{\mu },K_{C}^{a},K_{\bar{C}}^{a})$ the action
\begin{eqnarray*}
S^{*}(\Phi ,K) &=&\int \left( \frac{1}{4}F_{\mu \nu }^{a\ 2}+\frac{1}{%
2\lambda }\left( \partial \cdot A^{a}-K_{\bar{C}}^{a}\right) ^{2}-\bar{C}%
^{a}\partial _{\mu }D_{\mu }C^{a}\right) \\
&&-\int D_{\mu }C^{a}K_{\mu }^{a}+\frac{g}{2}\int f^{abc}C^{b}C^{c}K_{C}^{a}{,}
\end{eqnarray*}
satisfies the master equation $(S^{*},S^{*})=0$.
For other details and more general applications take a look at
D. Anselmi, Master functional and proper formalism for quantum gauge field theory,
12A3 Renorm
Eur.Phys.J. C73 (2013) 2363 | DOI: 10.1140/epjc/s10052-013-2363-4
and arXiv:1205.3279 [hep-th]