Let $\nu: M \to \mathbb S^n$ be a normal unit vector field along $M$, then the derivative $d\nu$ of $\nu$ maps $T_pM$ to $T_{\nu(p)}S = \nu(p)^\perp = T_pM$ and the Gaussian curvature is given by $$K_p = \det(d\nu(p): T_pM \to T_pM)$$
Now the volume form on $M$ is given by $\mathrm{d}vol_M = \iota(\nu) \mathrm{d}vol_{\mathbb R^{n+1}}$, i.e. for tangent vectors $\xi_1,\dots, \xi_n \in T_pM$ we have $$\mathrm{d}vol_M(p)(\xi_1, \dots, \xi_n) = \mathrm{d}vol_{\mathbb R^{n+1}}(p)(\nu(p), \xi_1, \dots, \xi_n) = \det(\nu(p), \xi_1, \dots, \xi_n)$$
Now consider the pullback $\nu^\ast \mathrm{d}vol_{S^n}$ of $\mathrm{d}vol_{S^n}$ to $M$:
\begin{eqnarray*}
\nu^\ast \mathrm{d}vol_{S^n}(p)(\xi_1, \dots, \xi_n) &=& \mathrm{d}vol_{S^n}\left(\nu(p)\right)\left(d\nu(p) \xi_1, \dots, d\nu(p)\xi_n\right) \\ &=& \det\left(\nu(p), d\nu(p) \xi_1, \dots, d\nu(p)\xi_n\right) \\ &=& K_p\cdot \det\left(\nu(p), \xi_1, \dots, \xi_n\right) \\
&=& K_p \; \mathrm{d}vol_M
\end{eqnarray*}
Therefore $$\int_M K \; \mathrm{d}vol_M = \int_M \nu^\ast \mathrm{d}vol_{S^n} = \deg(\nu) \int_{S^n} \, \mathrm{d}vol_{S^n} = \deg(\nu) \cdot \text{Volume }S^n$$
For even $n$, we have $\deg(\nu) = \frac{\chi(M)}2$, so I guess one might consider this to be a generalization to odd dimensional manifolds.
If $\nabla$ is any connection and $f$ a function, its Hessian with respect to $\nabla$ is $\mathrm{Hess}^{\nabla}f = \nabla \mathrm{d}f$, and one can see, after a messy calculation, that:
$$
\mathrm{Hess}^{\nabla}f(X,Y) - \mathrm{Hess}^{\nabla}f(Y,X) = \pm\mathrm{d}f\left([X,Y] - (\nabla_XY - \nabla_YX) \right)
$$
(where the $\pm$ sign is here because I don't remember the exact sign, but the computations are not that hard, just messy.) Hence, Hessians are symmetric if and only if the connection is torsion-free. This is the main motivation to consider torsion-free connections: in the euclidean space, Hessians are symmetric!
Moreover, the fundamental theorem of Riemannian geometry tells us that on a Riemannian manifold, there is a unique connexion that is torsion-free and lets the metric invariant, that is:
$$
\forall X,Y,Z, \left(\nabla_Zg\right)(X,Y) = Z\cdot g\left(X,Y \right) - g\left(\nabla_ZX,Y\right) - g\left(X,\nabla_ZY\right) = 0.
$$
(compare with the euclidean case, where $\langle X,Y\rangle ' = \langle X',Y\rangle + \langle X, Y' \rangle$.)
This theorem thus says that given any Riemannian metric $g$, there is a connection that is better than others: Hessians are symmetric and the metric is invariant under the action. We call it the Levi-Civita connexion.
If a connection is chosen, a geodesic is a parametrized curve satisfying the equation of geodesics : $\nabla_{\gamma'}\gamma' = 0$. Thus a curve $\gamma$ is a geodesic with respect to the connection, and can be a geodesic for some connection $\nabla^1$ but not for another connecion $\nabla^2$. Therefore, your question does not really have sense: we do not say that a connexion gives the least energy of a geodesic. I think you got confused, believing that being a geodesic is an intrinsic notion, but it really depends on the connection you consider.
Now, suppose $(M,g)$ is a Riemannian manifold endowed with its Levi-Civita connexion. Then if $\gamma : [a,b] \to M$ is a curve, we define its energy to be:
$$
E(\gamma) = \frac{1}{2}\int_a^b \|\gamma'\|^2
$$
and one can show that, in the space of all curves $\{\gamma : [a,b] \to M\}$ with same end points, a curve $\gamma$ is a point where the energy functional is extremal if and only if $\nabla_{\gamma'}\gamma'=0$, that is if and only if $\gamma$ is a solution of the equation of geodesics. Hence, a minimizer of the energy functional is a geodesic.
Best Answer
If by generalized Chern-Gauss-Bonnet theorem we mean that $\chi(M)=\frac1{(2\pi)^n}\int_M\textrm{Pf}(\Omega)$, where $\chi$ is the Euler characteristic, $\Omega$ is the curvature form, and Pf is the Pfaffian, then it is false for general connections. Beneventano et al. show in Heat trace asymptotics and the Gauss-Bonnet Theorem for general connections that when the connection is not Levi-Civita the correct integrand is not the Pfaffian. One can write a formula that works in general using the $L_2$ trace of the heat semigroup, but it is not nearly as useful.
Zhao proved a positive result in A note on the Gauss-Bonnet-Chern theorem for general connection. The connection need not be the Levi-Civita, but it has to be metric compatible. This means, in particular, that $\nabla g=0$ for some $g$, i.e. its restricted holonomy group is conjugated to a subgroup of $O(n)$, but it is not necessarily torsion-free, see Does the Levi-Civita connection determine the metric?