Solving an ODE which depends on an external function

Have you tried decreasing the tolerance? What’s the Mathematica code?