Compression is essential for reducing the size of movies so that they can be stored, transmitted, and played back effectively. Compression is achieved by an encoder; decompression is achieved by a decoder. Encoders and decoders are known by the common term codec.
No single codec or set of settings is best for all situations. For example, the best codec for compressing cartoon animation is generally not efficient for compressing live-action video. Similarly, the best codec for playback over a slow network connection is generally not the best codec for an intermediate stage in a production workflow.
When you create a movie for distribution, it is often highly compressed; when you create a movie for an intermediate stage in a post-production workflow, it is usually losslessly compressed (or even uncompressed).
If you want even more control over encoding and compression options, consider using Adobe Media Encoder or another dedicated encoding and compression application to convert losslessly encoded master files or image sequences exported from After Effects into files for final delivery.
In many cases, you can and should use encoding presets in Adobe Media Encoder, which is created for the specific purpose of setting up exports for common formats and uses. For information about several common encoding presets, see this: