Let $A$ be a (say finitely generated, unital) commutative complex $\star$-subalgebra of $B(H)$. Then, the self-adjoint elements form a real subalgebra $B:=A_h \subset A$, such that $B[i] = A$. Moroever, in $B$, we have
$$a_1^2 + \cdots a_n^2 =0 \quad \Rightarrow \quad a_1= \cdots=a_n =0,\quad \forall n.$$
The second condition is sometimes called real-reduced. (It implies in particular, that there are no nilpotent elements, hence the terminology.) I claim that these two conditions are also sufficient.
Theorem: Let $B$ be any finitely generated, unital, real and real-reduced algebra (with trivial involution). Then, $B[i]$ (with the obvious conjugate-linear involution) is a $\star$-subalgebra of $B(H)$.
Sketch of proof: The $\mathbb R$-points of $B$ form a closed real-algebraic variety, contained in $\mathbb R^n$ for some $n$. We may pick a bounded subset $X \subset \mathbb R^n$ and find $B[i] \subset C(X,\mathbb C) \subset B(L^2(X,\mu))$, for some suitable measure on $X$. q.e.d.
Finite generation of $B$ is necessary to give an easy characterization. Indeed, if $\bf R$ is some proper real closed extension of $\mathbb R$, then $B=\bf R$ is real-reduced, but ${\bf R} \not \subset B(H)$ by Mazur's theorem, which says that every subfield of $B(H)$ is either $\mathbb R$ or $\mathbb C$.