How to prevent OSX from putting a computer to sleep when a VM is running in VMWare Fusion
To paraphrase the iPhone ads, there's an app for that: Caffeine
It is a menubar app. Click prevents computer from sleeping, click again and the computer can sleep like normal.
Leave it plugged into the power adapter, and set this in System Preferences -> Energy Saver.
When its on battery, set it to sleep after however long you want.
This might not be the exact solution you're looking for, but I don't know of any software that will automatically handle this without some kind of intervention. Apps like Caffeine or InsomniaX require doing something and can be easily forgotten.