It depends on what time u sleep, so if you sleep at 9:00, you ca drink it at 5:00, and if you sleep at 10:00, you can drink at 6:00, you get the gist, right?
Anyways, you should probably stop drinking your coffee about three to four hours before bed, because there's also the issue of when to eat your food, you should them at separate times.