This is what I came up with and I am not sure if it is correct, and I would like to know if there is another, maybe purely geometrical, way of obtaining the equation.
A centroid will be the center of mass of a volume $V$ when the density of the mass in $V$ is constant $\rho \ne \rho(x,y,z)$. If $V$ is submitted to a constant gravitational acceleration $\mathbf{g}$, the equation for balance of torque for $V$ at point $\mathbf{x_c}$ becomes
$\int_V (\mathbf{x} - \mathbf{x}_c) \times \rho \mathbf{g} dx dy dz = 0$
Since $\rho$ and $\mathbf{g}$ are constant,
$- \rho \mathbf{g} \times \int_V (\mathbf{x} - \mathbf{x}_c) dx dy dz = 0$
which leads to
$\int_V (\mathbf{x} - \mathbf{x}_c) dx dy dz = 0$
Is this correct, and do you know another way to derive this equation?
By definition, we have$$x_c=\frac{\int_Vxdxdydz}{\int_Vdxdydz},$$or equivalently,$$x_c\int_Vdxdydz=\int_Vxdxdydz.$$Hence,$$\int_V(x-x_c)dxdydz=\int_Vxdxdydz-x_c\int_Vdxdydz=0.$$