In Einstein’s General Relativity, a spacetime-dependent metric defines the curvature of the manifold. Some studies however propose to resolve various celestial anomalies by allowing some anomalous acceleration to modify the law of inertia. If higher-derivative dependencies are allowed in an otherwise monogenic Lagrangian, the usual variational technique leads to a higher derivative extension of the Euler-Lagrange equations first presented by Ostrogradsky. Using this technique, to find the extremum of the spacetime interval, we derive the geodesic equation for a spacetime whose metric may have explicit dependence on the spacetime four-vector, four-velocity and four-acceleration. To exemplify its importance, we apply our result to some modified inertia models that accommodates some anomalous acceleration in their dynamics.