I would want to build in a way for the plane to try and save itself if possible (to save money) by auto-landing
Had the situation allowed saving the airplane the human pilot would definitely have tried that first.
The fact that a trained fighter jet pilot decided to eject from an aircraft knowing that the ejection was a last resort and could be deadly, signifies that the plane was not able to be flown safely anymore.
On top of numerous irrecoverable problems at that point, one of the most significant issues is the fact that ejection destabilizes the flight path and the increased drag (because there is no longer a canopy on top) makes it even harder to safely glide that jet, let alone land it somewhere.
There is nothing much autopilot can do at that point.
There have been two famous incidents that are related to your question but afaik neither of them involve Auto Pilot.
1989 Belgian MiG-23 crash Cornfield Bomber
It's just like saying
I know the airplane can be saved but my computer will take care of it
, I'm outta here.
See you at the Court Martial.
Some commentators have noted that I did not answer one basic question: Don't forget to answer the question "If a pilot ejects, what is the autopilot programmed to do?
", even if the question seems moot This question is too broad: there are numerous models of fighter jets all around the world, built by a number of manufactures and internal details of which are closely guarded secrets.
You are not going to generally find out a manual on the web listing all the actions that the autopilot software will perform after a bail out.
If the OP can narrow down the question to a certain model one can research and try to find something
but I don't believe its going to be an easy find.
Hence I'm sorry I don't have an answer to that question.
I hope someone more knowledgeable goes ahead and posts an answer to that.
aviation.stackexchange.com/users/1048/Hanky Panky
To add some context to the other answers...
Ejection is not a safe thing to do.
The two most popular ejection systems today, the ACES II and Martin-Baker, have around a 90-92% success rate...
the definition of success being the person lived.
Most ejections result in some injury to the person, as it is a fairly violent activity, with a brief 20g impact when the seat fires. FALSE
Almost all ejection occupants will suffer some form of spinal compression, typically they'll lose half an inch of height.
If the person doesn't follow protocol exactly, they may lose an arm on the way out.
If the head isn't perfectly in line with the spine, the neck can be broken.
Ejection is a measure of last resort, to be used only if the only other option is certain death.
So it's pretty much a given if the crew member fires the ejection seat, there is no other viable option, and the aircraft is uncontrollable, or will very soon be uncontrollable, by a pilot or an autopilot.
Also, if the aircraft is gyrating wildly, the seat can malfunction, or the occupant can be struck by parts of the aircraft, so waiting until the aircraft is completely out of control isn't a wise move, either.
aviation.stackexchange.com/users/22436/tj1000
Whatever it was programmed to do at the moment the pilot ejected.
Ejection seats are complex enough without integrating special processing of the event into the autopilot.
Since the autopilot can't land even an intact plane on its own, there's nothing it could do to save the plane.
Some ejections are indeed performed from aircraft that could potentially be saved, and have been landed with similar damage.
It's a matter of avoiding excessive risks from a gamble for an 80% chance of a safe landing and 20% a violent crash that sets the deck park on fire.
For certain historical reasons, many navies maintain an understandable bias against fires on the deck, and would prefer just ditching one plane.
On dry land, there's more latitude for crash landings.
As for preventing (or causing) collateral damage on the ground, the only way is for the pilot to point their plane somewhere and pray.
The autopilot is a reactive system - it doesn't concern itself with what's wrong or model the aircraft, just corrects what happens, so, possibly counterintuitively, it's often not too bad at controlling a damaged plane.
Since fighter control surfaces are large enough to counteract a lot of damage-induced drag, a working autopilot has a chance to maintain its last heading even with a damaged craft.
And that's as good as you could get with the current level of flight automation.
aviation.stackexchange.com/users/30268/Therac
It generally does nothing.
When a pilot ejects from the plane, that bird is screwed beyond saving.
There is no autopilot in the world which is sophisticated enough to fly a military plane even when it's fully intact, let alone when it's on fire and going down.
However, as I heard, there was a Su-27 model (or some descendant of the Flanker, maybe just a prototype?)
which had a peculiar easter egg: after ejection the onboard voice announcement system (the female voice which warns the pilot to certain things) talked for the last time: "
Good bye, and thank you on behalf of the fleet.
" There was nobody to hear it, and the pilot's helmet has already been disconnected by this time, so it was really just some engineer's idea of a joke.
I don't know if it's an actual feature in current Russian naval Flankers.
aviation.stackexchange.com/users/31783/Tamás Polgár
I imagine there's probably a switch such that over enemy or unknown territory the plane self-destructs.
But you don't want this over your own training areas such that some kind of controlled landing may be programmed in when in training mode.
aviation.stackexchange.com/users/31819/Testerson5
If a pilot uses his ejector seat during flight, what is the autopilot programmed to do?  As a developer myself, I would want to build in a way for the plane to try and save itself if possible (to save money) by auto-landing, or at the very least, calculate the nearest least-populated area for a crash-landing. So I'm wondering if anything like this is even written into the software.
If a pilot ejects, what is the autopilot programmed to do?
aviation.stackexchange.com
<military><autopilot><software><ejection-seat><autoland>
aviation.stackexchange.com/questions/52862
aviation.stackexchange.com/users/27677/Cloud
There is little an autopilot can do when a pilot ejects. It will continue to do what it was programmed to do when the pilot ejected. According to one answer, at the moment of the pilot's ejection, the autopilot cannot do anything more. According to another view, the  autopilot could only do whatever it was programmed to do according to its software, prior to the ejection. 
At the moment of the pilot's ejection, the autopilot cannot do anything more.  The  autopilot could only do whatever it was programmed to do according to its software, prior to the ejection. 