The derivative and expectation have the associative property (you can exchange the order) by Leibniz integral rule (computing the expectation is just some sort of integration)
$$\frac{\partial}{\partial \theta} \int_{a}^{b} f(x,\theta) d\,x = \int_a^b \frac{\partial}{\partial \theta} f(x,\theta) d\,x$$
(Note that not every operation has this property and you can have $f(E(X)) \neq E(f(X))$)