There is no optimum time to take vitamin D, however, taking it with a meal may help enhance absorption into the body and blood stream.
Saying this, it may be best to take vitamin D in the morning, as taking it at night may interfere with sleep. This is because Vitamin D can hinder the production of melatonin in the body, which is a hormone that controls our sleep cycle. However more research is needed into this.