If we assume the Earth to be a perfect sphere, then the force, with which the Sun (or the Moon, or any other planet for that matter) acts on the Earth is
$$\vec{F} \, =\, -\,\frac{GMm}{|\vec{r}|^3} \, \vec{r}$$
Where $\vec{r}$ is the vector pointing from the Sun to the Earth. The vector pointing from the Earth to the Sun is then $- \,\vec{r}$ and since the Sun acts with the force $\vec{F}$ from the position $- \, \vec{r}$ relative to the Earth, then the torque is
\begin{align}
\vec{T} \, =& \, (-\,\vec{r}\,) \times \vec{F} = (-\,\vec{r}\,) \times \left( -\,\frac{GMm}{|\vec{r}|^3} \, \vec{r} \right)\\
=& \, \vec{r} \times \left(\,\frac{GMm}{|\vec{r}|^3} \, \vec{r} \right)\\
=& \, \left(\,\frac{GMm}{|\vec{r}|^3} \, \right) \vec{r} \times \vec{r}\\
=& \, 0
\end{align}
Because by the properties of the cross-product $\vec{r} \times \vec{r} = 0$.
However, in reality, in terms of rigid-body dynamics, Earth is much better modelled as an ellipsoid of revolution and then the gravitational force is not radial, i.e. is not a multiple of the position vector $\vec{r}$ and in that case non-zero torques arise.
I wrote this post that derives in a fairly detailed mathematical way some models of Earth's rotational axis' dynamics under the torques exerted by the Sun and the Moon. Take a look at it if you are interested in the precession and nutation dynamics of Earth's axis of rotation.