How long will the suns energy last?

About 5 billion years. Long before that - in about 500 million or a billion years - the Sun will become so bright that it will become way too hot on Earth.