It is possible that $f$ is upper semicontinuous and there is no continuous $g$ above $f$, e.g. $f(x)=1/x$ for $x>0$ and $f(x)=0$ for $x\le 0$. (Edit: This example is wrong. A corrected example is appended at the bottom.) So the statement you want to prove is not valid.
If you add the assumption that there exists a continuous $g\ge f$ then the complete regularity of $X$ will suffice:
we can assume that $f(x)<g(x)$ for every $x$. Then for every $u\in X$ and every $r$ such that $f(u)<r<g(u)$ there exists an open neighborhood $U$ of $u$ such that $f(x)<r<g(x)$ for every $x\in U$.
Since $X$ is completely regular, there exists a continuous function $t\colon X\to [0,1]$ such that $t(u)=1$ and $t(x)=0$ for $x\in X\setminus U$.
Define $h:X\to \mathbb{R}$ given by $h(x)=g(x)-t(x)\big(g(x)-r\big)$.
Then $h$ is continuous, $f(x)< h(x)\le g(x)$ for every $x\in X$, and $h(u)=r$.
It then follows that $f=\inf\{g\in C(X)\!:g\ge f\}$.
In fact, the following theorem holds.
Let $X$ be a $T_1$-space. The following conditions are equivalent.
- For every upper semicontinuous $f\colon X\to\mathbb{R}$, if there is $g\in C(X)$ such that $g\ge f$ then $f=\inf\{g\in C(X)\!:g\ge f\}$.
- $X$ is completely regular.
Edit:
Let $X$ be a Dowker space.
Then there exists a decreasing sequence $\langle D_n\!:n\in\omega\rangle$ of closed sets with
$\bigcap_{n} D_n=\emptyset$ such that $\bigcap_n U_n\neq\emptyset$ whenever $\langle U_n\!:n\in\omega\rangle$ is a sequence of open sets
such that $D_n\subseteq U_n$ for every $n$.
Let us define $f\colon X\to\mathbb{R}$ by $f(x)=-1$ iff $x\in X\setminus D_0$ and $f(x)=n$ iff $x\in D_n\setminus D_{n+1}$.
Then $f$ is an upper semicontinuous function such that there is no continuous $g$ above $f$.
Otherwise, $U_n=\{x\!:g(x)>n\}$ would be open sets such that $D_n\subseteq U_n$ for every $n$, hence
$\bigcap_n U_n\neq\emptyset$, which is impossible.
Conversely, it can be proved that if $X$ is a normal space such that for some upper semicontinuous $f\colon X\to\mathbb{R}$ there exists no continuous $g$ above $f$, then $X$ must be a Dowker space.