I think $T$ is always an ideal of $C(X)$.
First note that the condition $f\in T$ may be rephrased as: $f$ possesses a zero in any infinite closed subset $C\subset X$. Indeed, if $f\notin T$, there is $g\in C(X)$ for which the closed set $C:=\{fg=1\}$ is infinite and $f$ has no zero there. Conversely, if $C$ is a closed subset of $X$ where $f$ does not vanish, we can extend $1/f_{|C}$ to a $g\in C(X)$, therefore such that the set $\{fg=1\}$ is infinite.
As a consequence we also have that $f\in T$ if and only if (i) $f$ vanishes identically on the derivate set of $X$, and (ii) $\operatorname{supp}(f)$ is countably compact.
Indeed, if $f\in T$ and $x$ is an accumulation point of $X$ any closed nbd of $x$ is an infinite closed set, so has a zero of $f$, and $x$ itself is a zero of $f$, and (i) holds. If $S$ is an infinite subset of $\operatorname{supp}(f)$ there exists a zero of $f$ , $x\in \overline{S} \subset\operatorname{supp}(f)$. Since in any nbd of $x$ there are points where $f$ is not zero, $x$ is an accumulation point of $\operatorname{supp}(f)$, and $\operatorname{supp}(f)$ is countably compact.
Conversely, assume $f$ verifies (i) and (ii), and let $C$ be any closed subset of $X$ with no zeros of $f$. It has no accumulation points because these points are zeros of $f$ by (i). Since $C\subset \operatorname{supp}(f)$, by (ii) $C$ is finite, that proves that $f\in T$.
We have thus proved that $T$ is the intersection of the ideal of all functions vanishing on $D(X)$ and the ideal of all functions wit countably compact support.