Since Mac OS X 10.6 Snow Leopard we have the ability to set how long your Mac is asleep or how long the screen saver is on before it requires a password to wake up again. However, you can’t enter your own custom time period.
defaults -currentHost write com.apple.screensaver askForPasswordDelay -int 1800
The number at the end a the command is the delay time in seconds. For example 1800 is 30 minutes.
Restart your Mac or logout/in to make the change active.