The amount of time before "the end" depends on what you expect to be ending.
Leaving aside the fact that the sun appears to be getting slightly hotter over time and thus within 1-2 billion years the oceans will boil away (or the fact that the earth is getting hotter on its own at an alarming rate *cough*), normal life on earth will become impossible around 5 billion years into the future when the sun either balloons out and swallows the earth, or (if it doesn't reach it) becomes a white dwarf that doesn't provide enough light and heat.
I'm going from memory here, but I believe it would take around 100 billion years for the universe to run out of enough hydrogen to make star formation impossible, from which point planets capable of sustaining life will become ever rarer and rarer.*
After that, we're talking timescales on the order of trillions of years, as black holes wander around swallowing everything/protons spontaneously decay/a few other random things. Supposedly the black holes will decay eventually as well, but Hawking radiation is still rather debatable at the moment. Okay, to be fair, the rest of these things aren't absolutely set in stone either, but most are still fairly well-supported.
I'm not a scientist myself, mind, so all this could itself be rather out-of-date by now. Speculation on the future of the universe is running at a fast clip at the moment.
__________
*One thing to note is, that it seems possible for complex life** to exist on a planet around a red dwarf under ideal conditions. Red dwarfs sustain their fusion reactions for a VERY long time. Some for possibly a trillion years or more (in general, cooler and smaller stars live longer), though these are a bit less likely to be able to sustain life. They also tend to produce loads of radiation, but that's why it's "seems" possible and not "definitely is" possible.
You wouldn't think something that's blood red/the colour of magma and called a "dwarf" would be good at sustaining life, but there you go.
**Simple life (archaeobacteria and the like) can live just about anywhere if it's adapted to it, the difficult part is getting it to form in the first place, though even that can occur in places more complex life would die a horrible, horrible death.