It is not clear whether you assume that "locally compact" includes "Hausdorff". Let us make this assumption here.
You can reduce the Urysohn lemma for locally compact spaces to the Urysohn Lemma for normal spaces which is a well-known theorem in general topology.
Let $X^* \supset X$ denote the one-point compactification of $X$. This a compact Hausdorff space, hence it is normal. The point added to $X$ will be deoeted by $\infty$.
$K$ and $L = X^* \setminus O$ are disjoint closed subsets of $X^*$. Note that $\infty \in L$. Choose disjoint open neigborhoods $U$ of $K$ and $V$ of $L$ in $X^*$. Then $\infty \in V$, thus $U \subset X$. Since $X^* \setminus V$ is a compact set contained in $X$ and $U \subset X^* \setminus V$, we get $\overline U^X \subset \overline{X^* \setminus V}^X = X^* \setminus V$, thus $\overline U^X$ is compact.
$K$ and $M = X^* \setminus U$ are disjoint closed subsets of $X^*$, thus there exists a continuous $F : X^* \to \mathbb R$ such that $F \mid_K \equiv 1$ and $F \mid_M\equiv 0$.
The restriction $f = F \mid_X : X \to \mathbb R$ has the desired properties:
Obviously $f \mid_K \equiv 1$.
The set $s(f) = \{x \in X \mid f(x) \ne 0\}$ is contained in $X^* \setminus M = U$. Thus $\operatorname{supp}(f) \subset \overline U^X$. Hence $\operatorname{supp}(f)$ is compact.
$\operatorname{supp}(f) \subset \overline U^X \subset X^* \setminus V \subset X^* \setminus L = O$.