Our current best understanding of the sun is that it will burn out in about 5 billion years. However, The real danger is that the sun burns brighter and hotter as time goes forward, and it is estimated that in 500 million years or so that the sun will be burning hot enough to boil the oceans! That would most likely be when life on Earth would end, barring some other event that ends all life on Earth. Pretty scary, right?
Now, let's think about scale. Human civilization has been around about 10,000 years. So, if we really only have 500 million years to go, that means we could have as much time as we had for human civilization so far, another 50,000 times. So, even if it took another 10,000 years to figure out space travel, we could come up with a way to escape just in case, and have a lot of time to spare!
For more details, check out http://en.wikipedia.org/wiki/Sun#Life_phases