Let G be an affine connected algebraic group, and K[G] be its coordinate ring. Let Y be a subvariety of G defined as a zero set for some f in K[G]. For which f, Y is a closed subgroup of G

It is perhaps easiest to express this in terms of Hopf algebras. The coordinate ring $K[G]$ has the structure of a Hopf algebra; the subvariety $Y$ is a closed subgroup of $G$ if and only if the ideal $(f)$ is a Hopf ideal, i.e. \begin{align*} \Delta(f) &\in (f) \otimes K[G] + K[G] \otimes (f); \\\\ \epsilon(f) &= 0; \\\\ S(f) &\in (f), \end{align*} where $\Delta$, $\epsilon$ and $S$ are the comultiplication, counit and antipode of the Hopf algebra $K[G]$, respectively. (See, for instance, Milne's freely available course notes on linear algebraic groups.) 

