Codec is a portmanteau of "coder/decoder", which describes a device or program capable of performing transformations on a data stream or signal. Codecs can both put the stream or signal into an encoded form (often for transmission, storage or encryption) and retrieve, or decode that form for viewing or manipulation in a format more appropriate for these operations. Codecs are often used in videoconferencing and streaming media solutions.
For instance, many multimedia data streams need to contain both audio and video data, and often some form of metadata that permits synchronization of the audio and video. Each of these three pieces of data may be handled by different programs, processes, or hardware; but for the multimedia data stream to be useful in stored or transmitted form, they must be encapsulated together.
The raw encoded form of audio and video data is often called essence, to distinguish it from the metadata information that together make up the information content of the stream and any "wrapper" data that is then added to aid access to or improve the robustness of the stream.
The codec is not to be confused with the video file format (or container) used to store the a/v information encoded by the codec. File formats like ".ogg", ".tta", ".mpg", ".avi", ".mov", etc. could be used to store information encoded by differenc codecs (eg. avi can contain DivX and Xvid also).
An endec is a similar (but not identical) concept for hardware.