Since the space has not been specified, we assume that $X$ is an open subset of the reals. The same proof works more generally.
Let $h(x)=f(x)-g(x)$. Let $x$ be any point such that $f(x)\ne g(x)$, that is, such that $h(x)=y\ne 0$. Let $U_y$ be an open interval about $y$ such that $U_y$ does not contain $0$.
Then by properties of continuous functions, $h^{-1}(U_y)$ is open. Thus there is an open neighbourhood of $x$ such that for all $u$ in that neighbourhood, $h(u)\ne 0$. (If $f$ and $g$ are continuous functions defined on the reals, instead of $h^{-1}(U)$, use the neighbourhood $h^{-1}(U)\cap X$.)
This implies that $\{x|h(x)\ne 0\}$ is open.
Remark: What follows is the answer to the first edition of the question, which did not assume continuity.
You need some continuity condition. Let $X=\mathbb{R}$. Then certainly $X$ is open. Let $h(x)=f(x)-g(x)$. Suppose that $h(0)=1$, and $h(x)=0$ for $x\ne 0$.
For example, we can take $f(0)=1$, $g(0)=0$, and $f(x)=0$, $g(x)=0$ for all $x\ne 0$.
Then $\{x|f(x)\ne g(x)\}$ is just the singleton $\{0\}$, which is not open.
The second question is equivalent to the first, since a se is closed if and only if its complement is open. So the second question succumbs to the same type of counterexample.
If we assume that $f$ and $g$ are continuous (or more weakly that $f-g$ is), there is a not difficult proof of the desired result.