The Wi-Fi device inside your phone (that includes the radio transceiver as well as the hardware that decodes the signals and tells the main CPU of the phone) has several different power states. Even when the Wi-Fi is on, after it's idle for several seconds, the Wi-Fi device goes into a low-power state. In this state, it's still connected, and can still receive data: when new data arrive via the connection, or when the phone wants to send some data, it quickly powers up to the working state.
The low-power modes aren't made visible to the user, so all you see is that the Wi-Fi is on or off, regardless of whether it's draining power because it's working all the time, or saving power by staying in the low-power state.
If you're using a custom ROM, it's possible that a bug in the driver integration is preventing the Wi-Fi device from going into its low-power state. It could also be caused by a poorly written app sending or receiving data very frequently for a long period: even if it's a small amount of data overall, if it's sent intermittently, it could keep waking up the Wi-Fi device, draining power unnecessarily.
As others have pointed out, you can choose for Wi-Fi to turn off completely when the device screen is off. This setting isn't always practically useful. If you have 3G turned on instead, then the phone actually uses more power to send data that way (but less power to stay connected-but-idle). If you have 3G turned off or it isn't available, then turning off Wi-Fi means you don't have any network connection at all, and can't get notifications of new mail &c. until a few seconds after you next turn the screen on.