Are you talking about Terminal Services? On Windows Server, or Windows Professional? Are you actually clicking "Log Off", or are you just closing the remote session?
If you are actually logging off by clicking the "Log Off" button, this deliberately ends your session, so there's nothing you can do in this situation. But if you're just hitting the "close" button, then this puts your session into the "Disconnected" state, and there are ways of changing those sessions.
If you are talking about Windows Server, you will find the options under
Session Host Configuration (It might be Remote Desktop Session Host Configuration if you're on 2008 or 2008 R2, or Terminal Services Session Host Configuration if you're on 2003).
If you open that menu item, you'll see something that looks like this:
Go to the Sessions tab, and you'll see all the settings you need: