You can reformulate your problem in terms of the language of geometric control (where your dynamical system is sometimes called Dubin's car). Let $$ X_1=\frac{1}{\sqrt{m}}(\cos\theta\partial_x + \sin\theta\partial_y),\qquad X_2=\frac{1}{\sqrt{I}}\partial_\theta$$ be a basis of your distribution $\mathcal{D}$. Horizontal curves are trajectories $\gamma :[0,T]\to M$$z :[0,T]\to M$ (here $M=\mathbb{R}^2\times S^1$ is the state space), that are tangent to $\mathcal{D}$the distribution, that is there exist $u_1,u_2:[0,T]\to \mathbb{R}$ (let us forget about regularity issues for $\gamma$ now), such that $$ \dot\gamma(t) = u_1(t) X_1|_{\gamma(t)} + u_2(t)X_2|_{\gamma(t)}, \qquad t\in [0,1] $$$$ \dot z(t) = u_1(t) X_1|_{\gamma(t)} + u_2(t)X_2|_{\gamma(t)}, \qquad t\in [0,1]. $$ Then, you want to findYou look for horizontal trajectories between fixed endpoints $\gamma(0),\gamma(1)$, that minimize the cost functional: $$ \int L(\gamma(t))dt = \frac{1}{2}\int_0^T (u_1(t)^2 + u_2(t)^2)dt $$$$ \int L(\gamma(t))dt = \frac{1}{2}\int_0^T \left(u_1(t)^2 + u_2(t)^2\right)dt. $$ (this should clarify the normalization we chosen for theof $X_1,X_2$).
This is a very simple optimal control problem. A generalAn application of the Pontryagin Maximum Principle yields first order necessary conditions for optimalitysolutions of this problem. In this very simple case your problem admits a Hamiltonian formulation, and hence all solutions can be found ascorrespond to projections on $M$ of integral trajectories of an Hamiltonian system on $T^*M$, with Hamiltonian given by
$$ H(\lambda) = \frac{1}{2}\sum_{i=1}^2 \lambda(X_i)^2, \qquad \lambda \in T^*M. $$
In canonical coordinates $(x,y,\theta,p_x,p_y,p_\theta)$ on $T^*M$, your Hamiltonian reads explicitly
$$ H=\frac{1}{2}(p_x \cos\theta + p_y \sin\theta)^2 + \frac{1}{2}p_\theta^2 $$$$ H=\frac{1}{2}(p_x \cos\theta + p_y \sin\theta)^2 + \frac{1}{2}p_\theta^2. $$
Then your "geodesic equations" correspond to the Hamilton's equations for $H$.
A good reference to this geometric-control approach to sub-Riemannian geometrygeneral kind of optimal control problems can be found in the following book (chapter 12, Theorem 12.10, case (b) is vacuous in your case, so only case (a) remains):
Agrachev, Andrei A.; Sachkov, Yuri L., Control theory from the geometric viewpoint., Encyclopaedia of Mathematical Sciences 87. Control Theory and Optimization II. Berlin: Springer (ISBN 3-540-21019-9/hbk). xiv, 412 p. (2004). ZBL1062.93001.>
or also, forFor a specifically sub-Riemannian reference, see Chapter 4.3 in
Agrachev, Andrei; Barilari, Davide; Boscain, Ugo, **AA comprehensive introduction to sub-Riemannian geometry. From the Hamiltonian viewpoint., ZBL07073879.
The references proposed by Robert Bryant are also very good, but the two aforementioned one are closer (I think) to the spirit of your question.