What was the name of the Ganesha before beheading done by Lord Shiva?
As per Shiva Purana, Ganesha didn't have actually any name. Just like Shiva has servants or minions who are known as gana, Parvati desired to have Her personal gana who would keep Her door. So She created Ganesha out of the dirt from Her body and told him he was Her son and ordered him not to allow anyone into Her residence.
Ganesha did as he was commanded and in course of events a battle ensued between him and Lord Shiva and his head was cutoff. Parvati got angry and hence the worlds started to face untimely anihilation. When sages requested Her to calm down, She demanded Her son to be brought back to life and crowned in a cheif position. So he became the chief of the ganas and hence known as Ganesha:
Gana+Isha (ruler) = Ganesha
Kartika Khanda Rudra Samhita of Shiva Purana
Parvati devi just called Him "son" (Putra). There are many birth stories of Ganesha described in Puranas. Each Purana describes story of a particular Kalpa and Shiva severing head happened in "Sveta Kalpa" which is mentioned in Shiva Mahapurana.
Some of the Puranas in which birth stories of Ganesha are mentioned are, Shiva Mahapurana (from Chapter 13 to Chapter 18 of Rudra Samhita- Kumara Khanda), Linga Purana (Chapter 105 of Part 1), Skanda Purana (Chapter 27 of Kaumarika Khanda of Maheswara Khanda) and Varaha Purana (Chapter 23).
In Linga Purana and Varaha Purana, Shiva directly creates Ganesha and in Skanda Purana, Parvati makes a boy with elephant head and Shiva immediately grants Him boons and makes Him leader of Ganas (Ganesha).
So, i will mention what Parvati Devi calls the boy in Shiva Mahapuarana which is of Sveta Kalpa.
After creating boy out of Her body dirt, she spoke to the boy following, in Chapter 13 Rudra Samhita Kumara Khanda.
मत्पुत्रस्त्वं मदीयोऽसि नान्यः कश्चिदिहास्ति मे।
एवमुक्तः स पुरुषो नमस्कृत्य शिवां जगौ।। २३॥
Then she said to him, “You are my son, you belong to me, there is no one else who could be called as mine, except you.” At these words of Parvati, the person, bowed in reverence to Pârvati and praised her.
हे तात! श्रृंणु मद्वाक्यं द्वारपालो भवाद्य मे।
मत्पुत्रस्त्वं मदीयोऽसि नान्यथा कश्चिदस्ति मे॥ २५॥
Parvati (Sivaa) said, "O Son, you listen to my Words. You function as my gate-keeper today. You are my son. No one else, except you, belongs to me.
विना मदाज्ञां सत्पुत्र! नैवायन्मद्गृहान्तरम्।
कोऽपि कृतापि हठात्तात ! सत्यमेतन्मयोदितम्॥ २६॥
O Son, no one should enter my house without my command, even forcibly. I have spoken truthfully to you."
She used "putra" and "tAta". TAta is term of affection addressed to any person who is younger, which means " O child - hey tAta".
When Ganesha fought with Shiva and other Ganas, devi Parvati thought in mind as follows, as mentioned in Chapter 14.
अहो क्षणं स्थितो नैव हठात्कारः कथं कृतः ।
कथं चैवात्र कर्त्तव्यं विनयेनाथवा पुनः॥४२॥
Parvati thought, “He has not delayed for a while, when these people have started using the force. Now my humility would be of what use?
भविष्यति भवत्येन कृतं नैवान्यथा पुनः। इत्युक्त्वा तु सखी तत्र प्रेषिता प्रियया तदा॥४३॥ समागत्याब्रवीत्सा च प्रियया कथितं हि यत्। समाचष्ट गणेशं तं गिरिजातनयं तदा।४४।।
Whatever has been destined to happen let it happen, but no adversity would happen." Thus thinking Parvati sent her sakhya to that place, who reaching there conveyed the words of Girijā to Gaņeša.
When Shiva cut the head of the boy, She used the word Putra to mention the boy which is mentioned in Chapter 17.
किं करोमि क्क गच्छामि हा हा दुःखमुपागतम्।
कर्थ दु:ख विनश्येतास्यातिदु:ख ममाधुना॥५॥
She thought within herself, “What should I do? Where should I go, alas I feel extremely painful. How could I be relieved of the pain of his death?
मत्सुतो नाशितश्चाद्य देवैः सर्वैर्गणैस्तथा।
सर्वास्तान्नाशयिष्यामि प्रलयं वा करोम्यहम्॥ ६॥
My son has been killed by all the god and the ganas of Šiva. Either I shall destroy them all or shall resort to dissolution.
Parvati devi changes her form to Chandika and says later she will be pleased only when Her son is resurrected.
मत्पुत्रो यदि जीवेत तदा संहरणं न हि।
यथा हि भवतां मध्ये पूज्योऽयं च भविष्यति॥४२॥
सर्वाध्यक्षो भवेदद्य यूयं कुरुत तद्यदि।
तदा शान्तिर्भवेलिोके नान्यथा सुखमाप्स्यथ।४३।।
The goddess said, “There would be no destruction, in case my son is brought back to life and becomes adorable by all of you. In case you agree to make him the chief of all the gods, only then the world would be peaceful and enjoy comforts, otherwise not.”
Thereafter elephant head is attached and Lord Shiva and other Devas granted Him boons.