With proprietary softphones (and locked ATA's) where all configuration settings are pre-set, you often will not have any choice over which codec is used for your calls.
If you have your own unlocked ATA (such as Cisco SPA112 or Linksys PAP2T-NA), or a configurable softphone, you usually will have some control over which codecs will take priority in your VoIP calls.
Some VSP's (VoIP Service Providers) that allow BYOD (bring your own device) will also allow you to select your preferred codecs to be used with their service. A couple examples are Voipfone.co.uk and sipgate.co.uk.
Other BYOD VSP's, will also provide a full range of standard codecs, but it may not be configurable from your web admin panel. Instead, just select your preferred codecs in your UA (user agent - i.e. configurable softphone or ATA). Many VSP's will recommend setting G.729a as your preferred codec and G.711u/a as the next option. Your UA will automatically select the preferred codecs upon call connection.
For VoIP calls that connect through the PSTN telephone network, G.711u/a and G.729a are the preferred codecs. G.711u/a provides the highest quality voice encoding (highest bandwidth usage), but G.729a provides the most effecient codec compression with good quality while using low bandwidth consumption. Most VSP's will recommend you set your user agent for G.729a as the preferred codec (to save bandwidth usage) and G.711u/a as the secondary, when high-bandwidth quality is absolutely required.
If your VoIP softphone or ATA is having problems sending "In-Band DTMF" tones, you will need to enable G.711u/a as your preferred codec.
If you connect a FAX machine to your ATA, you will certainly need to be set for G.711u/a codec. Some ATA's have a new special codec called T.38 which is specifically designed for best transport of FAX signals over VoIP lines.
In some configurable devices, you may not see G.711u/a on the list of available codecs. In these cases, you may see something else such as PCMA/PCMU. PCMU is equal to G.711u, and PCMA is equal to G.711a.