If they are on the same PNR, then AA in SFO will be able to tag the bags through to MEL. They will also give you both boarding passes.
You do have to change terminals at LAX, but TBIT is right beside T4. I believe there is an airside transfer bus between T4 and TBIT, but I've never used it. If you can do the airside transfer, and if all goes well, the two hours will be fine - but it leaves no real leeway for delays to the AA service.
Even if not on the same PNR, they should be able to tag it through anyway and give you both BPs.