Is the hepatitis b vaccine effective for life?

Maybe not. The Hepatitis B Vaccine is 2-3 shots. Some people may have protective antibodies for life, but many people's antibodies decrease as time goes by. Any person at high risk of contact with blood should get his antibody level checked, and get booster shots if his level is low. High risk persons include anyone with a household member who carries hepatitis b, healthcare workers, first responders, etc...
Up to 2 decades. Long-term studies indicate that Hepatitis B Vaccine provides protection up to 22 years.