Any bounded Borel function $f: \mathbb{R} \to \mathbb{R}$. If $TS = ST$ then (taking adjoint of both sides) $S^*T = TS^*$. Therefore both ${\rm Re}(S) = \frac{1}{2}(S + S^*)$ and ${\rm Im}(S) = \frac{1}{2i}(S - S^*)$ commute with $T$, and since they are self-adjoint it follows from standard spectral theory that they commute with $f(T)$. Taking linear combinations, $S$ commutes with $f(T)$.

Edit: here is a possibly more direct proof. Suppose $TS = ST$, meaning that $S$ preserves the domain of $T$ and they commute on this domain. Then the same is true with $T + iI$ in place of $T$ (since the domain doesn't change), and that operator is invertible. Multiplying both sides of $(T + iI)S = S(T + iI)$ by $(T + iI)^{-1}$ (no problems here, $(T + iI)^{-1}$ is bounded and takes everything into the domain of $T + iI$) yields $S(T + iI)^{-1} = (T + iI)^{-1}S$.

Now $(T + iI)^{-1}$ is normal (its adjoint is $(T - iI)^{-1}$), so by standard spectral theory $S$ commutes with every bounded Borel function of $(T + iI)^{-1}$. But every bounded Borel function of $T$ is also a bounded Borel function of $(T + iI)^{-1}$, QED.