As Harry has said, it's going to be difficult to assist you without knowing your machine and OS.
Couple of things to make sure of though - You say that you are going to upgrade the iPhone software to OSX Lion. You can't. I'm sure you're aware of this but Lion is a Mac OS, what you're wanting is iOS5.
To be able to download iOS5, you need to have the latest version of iTunes which is 10.5.1 which won't run on anything earlier than OS 10.5.
So, assuming your iMac is fairly new, and you're running at least OS 10.5 (Leopard) then this is what you have to do;
Download the latest version of iTunes (10.5.1). Once you've done that, you should just be able to hook up your iPhone to your iMac and iTunes will tell you that there is a software update available, which
should be iOS 5.0.1.
Before it performs the download, it will ask you to back up your iPhone. So just perform a sync as normal, then you are good to download the update. Once downloaded, the phone will do a few "strange" things, such as powering down and back up a couple of times. Whilst it's doing this, just leave it be and you shouldn't encounter any problems with it. It will then restore from the back up you made previous, and you're good to go!
But to reiterate what Harry said, we'll be able to give you some more precise information if you told us what model iMac and OS you're running.
Hope that helps somewhat.
EDIT: Didn't mean to just write a more convoluted version of Deckyon's post... It just took me an age to write it!