P0171 is a code for lean mixture. The main suspect is a vacuum leak into the intake manifold or throttle body. Start with the large hoses - the PCV and brake booster hoses. If you don't see anything, verify the code is "permanent" by driving a few hours and then clearing the code. Since you just replaced the O2 sensor I wonder if it is finally able to realize the mixture is lean or if it hasn't trimmed itself yet.
www.obd-codes.com