  As is well-known, the compact groups Spin(7) and SO(7) both have a single
conjugacy class of compact subgroups of exceptional type G_2. We first show
that if H is a subgroup of Spin(7), and if each element of H is conjugate to
some element of G_2, then H itself is conjugate to a subgroup of G_2. The
analogous statement for SO(7) turns out be false, and our main result is a
classification of all the exceptions. They are the following groups, embedded
in each case in SO(7) in a very specific way: GL_2(Z/3Z), SL_2(Z/3Z), Z/4Z x
Z/2Z, as well as the nonabelian subgroups of GO_2(C) with compact closure,
similitude factors group {-1,1}, and which are not isomorphic to the dihedral
group of order 8. More generally, we consider the analogous problems in which
the Euclidean space is replaced by a quadratic space of dimension 7 over an
arbitrary field.
  This type of questions naturally arises in some formulation of a converse
statement of Langlands' global functoriality conjecture, to which the results
above have thus some applications. Moreover, we give necessary and sufficient
local conditions on a cuspidal algebraic regular automorphic representation of
GL_7 over a totally real number field so that its associated \ell-adic Galois
representations can be conjugate into G_2(\bar{Q_\ell}).
