Let $(X, \mathcal F, \mu)$ be a $\sigma$-finite measure space and $(E, |\cdot|)$ a Banach space. Here we use the Bochner integral. Then we have Theorem 1.40 in Rudin's Real and Complex Analysis, i.e.,
Theorem Let $f \in L_1(X, \mu, E)$ and $F$ be a non-empty closed subset of $E$. If $$ \varphi(A) :=\frac{1}{\mu(A)} \int_A f \mathrm d \mu \in F \quad \forall A \in \mathcal F \text{ s.t. } \mu(A) \in (0, \infty), $$ then $f(x) \in F$ for $\mu$-a.e. $x \in X$.
Now let $(X, \tau)$ be a topological space, $\mathcal F := \mathcal B(X)$ its Borel $\sigma$-algebra, and $\mathcal C$ the collection of all closed subsets of $X$.
If $X$ is a metric space, then $\mu$ is both inner and outer regular. This means we can approximate a Borel set $A \in \mathcal F$ with $\mu(A) < \infty$ from above by open sets and from below by closed sets. By dominated convergence theorem and by the fact that $F$ is closed, we can strengthen above theorem by restricting the test sets $A \in \mathcal F$ to those $A \in \tau$ or to those $A \in \mathcal C$.
If $X$ is not a metric space, then $\mu$ is not necessarily regular. Is there a counter-example where above theorem fails if $X$ is a topological space and if we replace $A \in \mathcal F$ with $A \in \tau$ (or with $A \in \mathcal C$)?