Let $A$ be a commutative unital C*-algebra, and let $\tau$ be a state on $A$, so it is a linear functional on $A$ with norm 1 such that it takes positive elements to positive elements. Let $a \in A$ be a positive element. Let $f \in C(\sigma(a))$. When can it be said that $\tau(f(a))=f(\tau(a))$, if at all in general? If it helps, take $\tau$ to be moreover pure.
If you are asking for a fixed $\tau$ and for all $f$, then the answer is "precisely when $\tau$ is multiplicative on $C^*(a)$".
If you are asking for a particular $f$, question is not very well formulated:
for $f(t)=t$, the answer is "always"
for $f(t)=t^2$, the answer is "when $\tau$ is multiplicative on $C^*(a)$", and so the equality will hold for all $f$
for another $f$, who knows. It will depend heavily on specific properties of $a$ and $f$. For example, if $\tau$, seen in $C(\sigma(a))$, is a point evaluation, then $\tau(f(a))=f(\tau(a))$