You are correct. The P0031 code is for the heater circuit inside the upstream air/fuel ratio sensor (similar to an oxygen sensor, but a little more sophisticated). The P1148 code is for the closed loop control, which would be directly effected by the bad sensor. 99% of the time, it's the sensor that is the fault. My advice would be to go ahead and replace the upstream sensor, erase the code and clear the self-learning in the ECM. For the sensor, you will need to find out if the vehicle has Federal or California emissions certification, which will be listed on the sticker under the hood. Rockauto.com sells the sensor. I would recommend sticking with either NTK or Denso brand; Denso will be a little less expensive.
For Federal emissions, you can go with Denso 2349038 or NTK 25679
For California emissions, you can go with Denso 2349036 or NTK 25685