According to C. Evans' book Introduction to stochastic differential equations, we consider the following control problem:
Let $U\subset R^{m}$ be a bounded, smooth domain. Suppose $b: R^{n} \longrightarrow R^{n}$, $B: R^{n}\longrightarrow M^{n.m}$ has usual assumptions
Then for $x\in U$ the stochastic differential equation:
$$dX=b(X)dt+B(X)dW.$$
$$X_{o}=x.$$
has a unique solution. Let $\tau_{x}$ denote the hitting time of $\partial U$. Let $\theta$ be any stopping time with respect to $F(\cdot)$, and for each such $\theta$ define the expected cost of stopping $X(\cdot)$ at time $\theta \wedge \tau$ to be
$$J_{x}(\theta) = E\left(\int_{0}^{\theta \wedge \tau} f(X(s))ds+g(X(\theta \wedge \tau))\right).$$
We consider the value function
$u(x)=\inf_{\theta} J_{x}(\theta)$.
Then optimality conditions:
Assuming that $u$ is smooth enough then we can prove:
1) Let $\theta=0$, we get $u(x) \leq g(x)$.
2) At $x\in \partial U$, $u(x)=g(x)$.
3) $0\leq f(x)+Lu(x)$, where $L$ is infinitesimal generator of $X(t)$ (also elliptic operator).
The problem is that I don't know why $0=f(x)+Lu(x)$ for $x$ satisfies $u(x)<g(x)$.
Let $x \in U$ be such that $u(x) \lt g(x)$. Recall that, by point 3 of your question, $f(x) + Lu(x) \ge 0$. Suppose that $\tau$ is the first stopping time minimizing $J_x(\theta)$, i.e., $$ u(x) = \mathbb{E}\int_0^{\tau} f(X(s)) \, ds + \mathbb{E}\, g(X(\tau)). \tag{1}\label{1}$$ Then it follows that $$ \mathbb{E}[g(X(\tau))] = \mathbb{E} [u(X(\tau))].$$ Indeed, suppose that it is not true, then $\mathbb{E}[g(X(\tau))] > \mathbb{E} [u(X(\tau))]$ and, by Itô's formula for stopping times, $$ \mathbb{E}[g(X(\tau))] > \mathbb{E} [u(X(\tau))] = u(x) + \mathbb{E} \int_0^\tau Lu(X(s)) \, ds,$$ that is, by eq. \eqref{1}, $$ \mathbb{E} \int_0^\tau \left( Lu(X(s)) + f(X(s)) \right) ds < 0, $$ a contradiction.
Now, $$ u(x) = \mathbb{E} \int_0^\tau f(X(s)) \, ds + \mathbb{E} \, u(X(\tau)), $$ and, again by Itô's formula, $$ \mathbb{E} \int_0^\tau \left( f(X(s)) + Lu(X(s)) \right) ds =0. $$ Recall that $Lu+f \ge 0$ and, hence, $Lu(x) + f(x) = 0$ as claimed.