billmcd has give a good rule that covers most cases. A fuller overview of the whole sysyem of adding -ing follows, with the sections relevant to doubling printed in green:
-ing is added to the first form: playing, working, understanding,
Most verbs ending in single mute -e drop the final –e before –ing, though if word-final –e is preceded by –y, -o or –ng, or if the verb ends in –ee, the –e is retained:hiring, becoming, reclining but: dyeing, toeing, whingeing, freeing
Polysyllabic verbs ending in –ge generally drop the –e; impinging, infringing
Retention of the –e in AGE is optional: aging or ageing
Verbs ending in –ie change this to –y before –ing: tying, dying
Verbs ending in a single consonant letter (except –w, –x , -c and -l ) following a single vowel letter in a stressed syllable double that final consonant before adding the –ing: robbing, knitting, referring but revealing, rowing, boxing.
Verbs ending in –c add -k rather than doubling the –c. This occurs even when the final syllable is unstressed.: picnicking, panicking.
In BrE, word-final –l is always doubled after a short vowel sound, even in unstressed syllables: repelling, levelling, travelling, cancelling
In verbs with a final unstressed syllable ending in –s,some writers double the final –s of the first form before adding the –e; this is optional: biasing or biassing, focusing or focussing
There is no doubling when the final syllable is unstressed (except for verbs ending in -c and -l): happening, bothering, visiting
However, a small number of verbs double the final consonant in BrE even if the final syllable is unstressed. This may be because the final syllable exists as a single-syllable (hence stressed) verb, even if the polysyllabic verb is not actually a compound: programming, handicapping, hiccupping, kidnapping, worshipping.