To find a Cartan subalgebra for $\mathfrak{su}(n)$ we take advantage that $\mathfrak{su}(n)$ consists of anti-hermitian matrices. If a set of elements of $\mathfrak{su}(n)$ commute then they can be simultaneously diagonalized. This means that if we take a linearly independent set $\{X_a\}$ of commuting elements (which we shall take as a basis for the Cartan subalgebra), we can always find a unitary $U$ such that the set $\{U^\dagger X_a U\}$ is a set of linearly independent diagonal matrices.
Thus a Cartan subalgebra can be generated by a maximal set of diagonal matrices of zero trace. This yields a subalgebra of dimension $n-1$ with the generators of the form $$\begin{pmatrix}i & 0 & \cdots & 0\\ 0 & 0 & \cdots & \vdots\\\vdots & \vdots & \ddots & \vdots\\ 0 & 0 & \cdots & -i\end{pmatrix},\quad \begin{pmatrix}0 & 0 & \cdots & 0\\ 0 & i & \cdots & \vdots\\\vdots & \vdots & \ddots & \vdots\\ 0 & 0 & \cdots & -i\end{pmatrix},\quad \dots$$
Now for $\mathfrak{so}(n)$ this seems harder. The elements have zero diagonal so we cannot even expect to have some clever argument that allows us to look for diagonal matrices.
My only idea was to take the usual basis $\{E_a\}$ of $\mathfrak{so}(n)$ fix $X_1 = E_1$ and then look for matrices commuting with $X_1$. Then inside that subspace pick some $X_2$ and look for matrices commuting with $X_1,X_2$, and so on, until not being able to find any other matrix. This seems to work for specific values of $n$, but there ought to be a better approach for general $n$ like $\mathfrak{su}(n)$.
So: how do we find a Cartan subalgebra for $\mathfrak{so}(n)$?