The real problem is solving the differential equation, for different values of parameters. To do this it's useful to write the solution in a useful basis of functions and using interpolation for everything else.
Add an extra variable (call it s(t), for example) and add the differential equation
ds/dt = g(t,x)
with initial value s(t0) = 0. Then at the end time T, s(T) is the numerical estimate of the integral of g(t,x(t)) from t = t0 to t = T. It has the same order of accuracy as every other part of the solution to the differential equation.