There is no "last flight" time, Heathrow is open 24 hours. As you are probably aware there are a limited number of night flight slots, ie between 2300 and 0600. Over time these have tended to get concentrated in the hands of those airlines with large aircraft they wish to arrive shortly before 0600. But if any operator has one of these slots they could depart at 0145 each night if they wished. It is just that, commercially, it is more effective to go for those early morning arrivals.
Such a unplanned night departure has to be taken from the night slot allowance. So if it was BA (just as an example) who had a late evening departure delayed several hours, one of their early morning arivals will have to be rearranged to arive after 0600. This sort of on-the-day adjustment happens from time to time.
It used to be that there were several freight flights in the middle of the night, but these have been squeezed out by the early morning arrivals within the night times. The night flights allowed are expressed at so many per year which gives some flexibility, and 99%+ actualy get used.