Under the assumption of regularity of $Y$ this is true. The proof below was derived from Bourbaki "General topology" (Theorem I.8.5.1). They also provide a counterexample for arbitrary non-regular space $Y$ (so given $Y$ they construct $X,E,f,g$ s.t. all your conditions are satisfied, but continuity of $h$ fails) - Exercise 19 in I.8. This counterexample is somewhat complicated (not mentioning that the construction of a non-regular Hausdorff space is already a nontrivial problem). Before reading the proof note that I use the term "neighborhood of a point" in the sense of Bourbaki, i.e. it means a set that contains this point in its interior.
Assume that $Y$ is regular (that is, for each $y \in Y$ and a neighborhood $U \subset Y$ of $y$ there is a closed neighborhood $F \subset Y$ of $y$ s.t. $F \subset U$) and consider $x \in E \cup S$. Let $F \subset Y$ be a closed neighborhood of $h(x)$. I claim that there exists an open set $U \subset X$ such that $x \in U$ and $f(U \cap E) \subset F$. Indeed, if $x \in E$, then it is true by continuity of $f$ and, if $x \in S$, then it is true by the assumptions on $f$ and $g$. It remains to show that $g(U \cap S) \subset F$. Let $z \in U \cap S$. Since $z \in \overline{E}$, it follows that in all neighborhoods of $z$ there are points from $U \cap E$, and by the assumption that $f(x) \rightarrow g(z)$, when $x \rightarrow z$, we obtain that $g(z) \in \overline{f(U \cap E)}$. So, $g(z) \in \overline{f(U \cap E)} \subset \overline{F} = F$. Therefore, $h(U \cap (E \cup S)) \subset F$ and by regularity of $Y$ (note that we considered only closed neighborhoods of $h(x)$) we obtain continuity of $h$.