Term in Lagrangian Invariant under $SO(n)$ but not $O(n)$? In condensed matter physics or quantum field theory we often write down terms in our Lagrangian which are invariant under given symmetries. The standard model for example is invariant under $SU(3)\times SU(2) \times U(1)$ (spare spontaneous symmetry breaking) - whilst a typical free energy in the Heisenberg model is:
$$H=\int d^3\vec r\left(\frac{1}{2} \nabla_i M_j \nabla_i M_j+a_2 \vec M \cdot \vec M+a_4(\vec M \cdot \vec M)^2+\cdots\right)$$
It is clear in this case that is invariant under $SO(3)$ and $O(3)$.
My question is - in general what terms can we add to Lagrangian (in CPM and QFT) to make it invariant under solely $SO(n)$ ($SU(n)$) rather then $O(n)$ ($U(n)$)?
 A: Take a field theory with a scalar field $\phi_i$ as a multiplet of $O(N)$, where $i$ is the $O(N)$ index.
You can construct two scalar combinations:


*

*$\phi_i \phi^i$ that is both $O(N)$ and $SO(N)$ invariant

*$\epsilon^{i j k \dots}\phi_i \phi_j \phi_k\dots$ that is $SO(N)$
invariant but not $O(N)$ invariant.
So a Lagrangian that contains some combination of the second term will be only $SO(N)$ invariant.
EDIT for clarification: The term  $\epsilon^{i j k \dots}\phi_i \phi_j \phi_k\dots$ is zero written like this, but adding derivatives makes it non zero without changing its transformation properties. For example 
$$\partial_\mu \phi_i \partial_\nu\phi_j \partial_\sigma \phi_k \epsilon^{ijk}\epsilon^{\mu\nu\sigma\rho}V_\rho$$
is $SO(3)$ invariant and non zero (where $V_\rho$ is some Lorentz vector).
A: The answer is fundamentally different for global vs. gauge symmetries. For global symmetries FrodCube's answer is correct, but for gauge symmetries in a continuum field theory (like the one you mention in your question), the gauge group must be connected because the gauge field must be continuous. So it doesn't make sense to have a disconnected gauge group like $\mathrm{O}(N)$ in a continuum gauge field theory.
