I've often wondered if he named St. Petersburg as such because he knew its importance as the last possible fall-back position, or was it an accidentally chosen city that he poured the souls of Russians into simply because it bore his name.
Well, Stalingrad wasn't actually St. Petersburg, Stalingrad is the modern day city of Volgograd. St. Petersburg was known as "Leningrad". So assuming you are still referring to the battle of Stalingrad and not the siege of Leningrad, there are several reasons Stalin wanted to keep control of Stalingrad. Now to get some background on the whole battle. The Germans had lost their ability to do front wide assaults in 1941, and so in 1942 they had to focus on a single area. Hitler choose the Caucuses because they contained vast oil reserves that Germany needed to keep fighting. So the plan for attacking the Caucuses, called "Case Blue", relied on two army groups, A and B.
Army Group A would take the actual Caucuses, while Army Group B would secure their northern flank and take the Volga region. Now at the start the most important things would be capturing the Caucuses and dealing a blow to the Red Army. Stalingrad was initially not the focal point of the campaign, the Germans knew that Stalingrad would have to be neutralized, but it wasn't paid much attention at the start of the offensive. Hitler would later attach importance to the capture of the city because of its symbolic value. Hitler's generals would later blame Hitler for creating two army groups and moving the focus away from the Caucuses; but the truth is, the creation of two army groups was necessary for the campaign to work. And the capture or at least the threatening of Stalingrad was also necessary, otherwise the armies in the Caucuses were under threat of being cut off. Now why was Stalingrad an important city? A few reasons:
It was a vast industrial centre that contained Soviet weapons factories
It was a vital transportation hub, with a vast railway network that enabled supplies to get through the Caucuses into Russia proper
It held control over the river Volga and any advance into the Caucuses would be threatened by whoever held Stalingrad
And yes there was a political factor as the city did hold the name of the leader of the Soviet Union and it was a fairly major Soviet city
So no, Stalin didn't hold onto Stalingrad because of his ego, rather he held onto it because the actual city of Stalingrad was important, and holding Stalingrad allowed the Soviets to not only destroy the German sixth army, but end the German threat to the Caucuses. Because of the way the Germans fought, with very lighting quick attacks backed up with substantial firepower, the best counter was to fortify and let the German attackers wear themselves out before counter attacking. Does this method lead to a lot of casualties? Unfortunately yes, but its effective none the less.
My sources for all this are "Victory at Stalingrad" by Geoffrey Roberts and "When Titans Clashed" by David Glantz