Let's assume $M$ is connected and $n$-dimensional. A subalgebra of $H(M)$ is Lagrangian if and only if its vector space dimension is one half that of $H(M)$ and $K^n=0$. If $n=2q+1$ then there are always such subalgebras. One of them has $K^i=H^i(M)$ if $i$ is even and $H^i(M)=0$ if $i$ is odd. Another has $K^i=H^i(M)$ if $i=0$ or $q<i<n$ and $K^i=0$ if $0<i<q+1$ or $i=n$. If $n=2q$ with $q$ odd, then you can always make an example by choosing $K^q$ to be Lagrangian with respect to the alternating Poincare duality form on $H^q(M)$ and putting $K^i=H^i(M)$ if $i=0$ or $q<i<n$ and $K^i=0$ if $0<i<q$ or $i=n$. If $n=4k$ then you can do the same thing if the symmetric Poincare duality form on $H^{2k}(M)$ has a "Lagrangian form" (i.e. if the signature of the manifold is zero), but there is no Lagrangian subalgebra if the signature is not zero.