Military pay is more complicated than civilian pay. First, unlike civilian physician pay, it rises both with time in service and with promotions. More importantly, a huge percentage of your compensation comes in the form of three big payouts: the scholarship itself, the ability to transfer the GI bill to a dependent (if you stay in for 10 years) and the military's pension plan (if you stay in for 20 -30 years).
Due to the incredibly high/rapidly rising cost of medical school, as well as the insane interest rates on graduate loans, most specialties come out ahead by taking the HPSP scholarship compared to taking civilian loans and then getting out after 4 years. Highly paid surgical specialties now almost break even, and primary care can come out way ahead vs their civilian peers.
Full discussion here. The only people who really lose money by taking HPSP are the people who are forced to take a lower paying specialty in the military match than they would have gotten in the civilian match, or people who ruin their working spouse's career by having to move to remote locations for the military. Both are really serious risks of committing to the military.
Almost all doctors will lose money relative to their civilian peers by staying in the military after their initial obligation, unless they stay for a full 20 years to get a pension. Career physicians who stay for the pension usually come out ahead if they are in a lower paid specialty (peds, psych, family, Ob/Gyn) but will generally lose money if they are in a higher paid specialty (ER, Gas, Rads, Surgery). Unless you stay in for 20 years, taking USUHS over HPSP will usually cost you money in the long run.
Keep in mind its not just the money that varies between specialty, but also the quality of life. Generalists like Pediatricians, Ob/Gyns, Family docs, and Psychiatrists may come out financially ahead after 20 years in the military, but they will spend most of those years in really unpleasant, rural locations even when they're not deployed. On the other hand subspecialists like Pediatric Nephrologists and Maternal Fetal Medicine docs might not just come out way ahead financially, but may also spend their entire career glued to a single major hospital in a highly desirable area.