You need to change the basal rate ahead of when you want to see the change take effect. However, while the "2 hours before" value is always thrown out there, keep in mind that it is only yet another "rule of thumb". These always are a best fit for the fictional average person.
We all need to start someplace when tweaking a basal, but what really matters is what works best for your experience of D in your body. Quite possibly that means changing 2 hours ahead. But maybe it means 3 hours, or 1 or 1 1/2, or ...