For CD, you have no choice. It
must be 44.1 KHz and 16 bits to satisfy the specification and be playable on CD players.
This will tell you all about it.
For other formats, it depends on the software you use for encoding. FLAC encoders can handle any file format, including 32-bit floats and high sample rates, so if you're exporting for FLAC encoding leave the export file the same as your project (and don't dither).
MP3 encoders work best if you give them the highest-quality format they can handle. The most widely-used encoder, which is also used by SONAR, is the free open-source LAME. Some versions, like some other MP3 encoders, can't process 32-bit files, so you might need to export 24-bit files for them. Some encoders can't handle some sample rates, so if you're recording at 48 or 96 KHz, make sure the encoder you're using can deal with it. LAME can, I think. If you're recording at 192 KHz, just stop doing that.
The most important factor when encoding to MP3 is not the source file format but rather the target bitrate. If file size is not an issue, encode to 320 kb/s. Keep in mind that many file-hosting sites automatically re-encode your MP3s to 128 kb/s for streaming, but that process will work better against a 320 kb/s source file than if you send a 128 kb/s file that doesn't need to be re-encoded. So always use the highest bitrate possible (you may have to compromise if a host site has a file size limit).
Somebody is likely to point out that you can't hear the difference between 320 and, say 192 kb/s. It's mostly true. You have to listen very closely to specific high-frequency elements to hear any difference. However, you don't know what might be subsequently done to your file, such as converting back to wave or re-encoding to a lower bitrate. 320 lets you keep the best quality possible for any further processing.