Howdy there,
I have worked it out several times actually. I will give a brief overview of what I have done with approximations for numbers, as they are all could be changing soon. Some things to keep in mind:
Whether or not you gain/lose money really depends on what specialty you enter and the cost of attendance for your school. In my two examples, I will use family practice and general surgery. At the end I will post some more info so you can reach your own conclusions.
Basically, you can break up the benefits into 3 blocks: medical school, residency, and attending.
MEDICAL SCHOOL
The value for your medical school is, obviously, the total of what the military pays you ever year. My school is around $35,000 a year, with an additional $5,000 for insurance tacked onto tuition. So the military is paying $40,000 a year for me to attend. I am also getting a stipend of $1319 per month for all but 45 days of the year, during which time I actually get around $2800. So roughly I will get about $16,000 in pay. (NOTE: There is currently a bill in congress, which has already passed both the house and senate, that raises the stipend. Currently we are expecting the stipend to increase to approximately $2,500 per month)
So, the value of the scholarship is actually $56,000 per year. You can actually still take out loans if you wish depending on whether or not your school includes the stipend in the scholarship; some do, some do not. Mine does not, so I can actually still take out the difference between the school's budget and what the military is paying them. This ended up being $17,000 a year.
Over the course of four years, the military is paying $224,000.
RESIDENCY
Military residents make nearly twice what civilian residents make. Most civvy residents earn something between $30,000 and $40,000 per year. Military residents, since they are active duty, receive active-duty pay for their rank. Military pay is composed of base pay for your grade, time in service, housing allowance, subsistence allowance, and any bonus pays to which you are entitled -- bonus pays become very important once you become an attending. The current annual salary chart can be found here:
http://usmilitary.about.com/library/milinfo/pay/bl06offsalary.htm
Any resident will be an O-3 (Captain in the AF/Army, Lieutenant in the Navy); you are promoted to O-3 from O-1 when you graduate. I do not know if your four years of med school count as time in service; I assume they do. Thus, your annual salary as an O-3 is $75,295.71. I think you also get a couple of bonus pays but I'm not sure.
For Family Practice you do a 2-year residency, so you end up making $150,000 while a civilian FM resident has made around $70,000.
ATTENDING
This is where it gets tricky. As an attending your pay is based on: time in service, pay grade (rank), specialty, board certification status, years contracted, etc. The bonus money really racks up. A list of the special pays can be found here
http://www.military.com/Resources/ResourcesContent/0,13964,42822--1,00.html
As a primary-care doc, you really do not lose much money as an attending, so you have quite awhile before you start to "lose" money (when the money lost to the military's lower salaries is no longer offset by the value of the scholarship). For general surgery, this happens around 5 years of active duty time.
For a quick answer to your question:
Military FP makes somewhere around $118,000 after the annual salary and the bonuses. Civilian FPs make around $130,000 I think. Losing $12,000 you have a long time before going this route actually makes you lose money overall.
For gen surg, it's a different story. A military GS makes around $134,000, nearly $100,000 a year less than his civilian counterpart.
I hope I somewhat answered your question. Do not let finances be a determining factor though. There are also other benefits, such as not having to worry about getting a high-paying specialty to pay off your debts and still live like you want. I actually feel a lot more "free" to do what I want.
Good luck.