You can find an explicit counterexample in the Riemannian Schwarzschild solution.
Let $(z,r,\omega) \in \mathbb{R} \times (1,\infty) \times \mathbb{S}^2$, denote by $h$ the standard sphere metric. Consider the following Riemannian metric
$$ ds^2 = (1- r^{-1})~dz^2 + (1-r^{-1})^{-1} ~dr^2 + r^2 h $$
One can explicitly compute that this metric is Ricci-flat using:
- The metric is a warped product of $\mathbb{R}\times (1,\infty)$ against the sphere,
- Exercise 5.5 from O'Neill's Semi-Riemannian Geometry
- Standard formulae for the Gauss curvature of a diagonal metric in two dimensions.
As a warped product, fixing any $\omega\in \mathbb{S}^2$, the submanifold $\mathbb{R}\times (1,\infty) \times \{\omega\}$ is totally geodesic, but it has non-vanishing Gauss curvature $K = \frac{1}{r^3}$ and so is not Ricci flat.
(I think you also have a co-dimension one example if you look at a $z$-level set, which is totally geodesic due to the reflection symmetry in $z$. I am pretty sure that this slice also has non-vanishing Ricci curvature.)
Because any $z$-level set is asymptotically flat, if such a set were not Ricci flat then Bishop-Gromov comparison would imply that the level set is isometric to Euclidean space. This is clearly false, as can be seen by, say, calculating the Riemann curvature, or by computing the ADM mass of the level set.
Best Answer
Contrary to another comment/answer, totally-geodesic $1$-manifolds in $S^3$ are not trivial because they can be disconnected. Great circles do not have to intersect, as can be seen by taking generic planes through the origin in $\mathbb{R}^4$.
Geodesics sometimes can't be isotoped to fibers of the same Hopf fibration. Great circle links were the subject of G. Walsh's thesis. One chapter classified great circle links up to $5$ components. There are $1,1,2,3,7$, respectively.
In higher dimensions, there are disconnected geodesic submanifolds of $S^n$ of dimension up to $(n-1)/2.$ The only place where you can have interesting linking is with totally geodesic $d$-spheres in $S^{2d+1}$, and I think the link theory is always nontrivial in that dimension.