Fix $n\ge 2$. For every nondegenerate quadratic form $q$ in dimension $n$ over a field $K$ of characteristic zero, the maximal dimension of the centralizer of a nonzero element of $\mathfrak{so}(q)$ is $n(n-1)/2-(2n-4)$ (i.e. the minimal codimension is $2n-4$. $\DeclareMathOperator\so{\mathfrak{so}}$
[Edit: this is incorrect. The minimal codimension is between $2n-4$ and $2n-6$, so the question is not settled at this point.]
Proof:
(1) The first part is to show that codimension $2n-4$ is achieved. This is actually easy. Diagonalize $q$, and thus choose an orthogonal decomposition of the ambient space as $V=V_2\oplus V'$ with $V_2$ 2-dimensional. Choose a nonzero element $g$ of the 1-dimensional $\so(q|_{V_2})$. Extend it as zero on $V'$. So we can view $g$ as an element of $\so(q)(K)$. Then its centralizer has codimension $2n-4$. Indeed, to compute it, we can extend extend scalars to assume $K$ algebraically closed (this is inessential, just simplifies computations), and hence we can suppose that the basis is orthonormal. Then $\so(q)$ is the space of skew-symmetric matrices and the centralizer of $g$ consists of those with the (linearly independent) conditions $g_{ij}=0$ for $i=1,2$, $j=3,\dots,n$.
(2) Now let us show that codimension $2n-6$ is an lower bound for the dimension of the centralizer of a nonzero element $g$. For this, we can assume from the beginning that $K$ is algebraically closed. Now I borrow the argument from this answer by Peter McNamara: we can suppose that (the projection of) $g$ belongs to closed adjoint orbit in $\mathbf{P}(\so_n)$ (indeed passing from a non-closed orbit to its boundary decreases the orbit dimension and does not decrease the dimension of the centralizer). And (see that same answer), this means that $g$ is, up to conjugation, a nonzero element in a root space. Fixing a Cartan subalgebra, we have 1 or 2 orbits of roots according to whether $n\ge 4$ is even or odd (call them long roots and short roots, assuming that for even $n$ there are only long roots — for $n=3$ there are only short roots). In both cases the computation shows that these root spaces have a centralizer of codimension $2n-4$. (Edit: the long roots have a centralizer of codimension $2n-6$. Whence this lower bound on the codimension. The short roots have a centralizer of codimension $2n-4$, but this is a priori only relevant for $n=3$.)