As a racial epithet in British English
Wog is in the UK usually regarded as an offensive slang word referring to dark skinned, non-white people from Africa or Asia. The origin of the term is uncertain. Many dictionaries say "wog" possibly derives from the Golliwogg, a blackface minstrel doll character from a children's book published in 1895. An alternative is that "wog" originates from Pollywog, a maritime term for someone who has not crossed the equator.
It was first spotted by a lexicographer, F.C. Bowen, who recorded it in 1929 in his Sea slang: a dictionary of the old-timers’ expressions and epithets, where he defines wogs as “lower class Babu shipping clerks on the Indian coast”. 
The use of the word is discouraged in Britain, and most dictionaries refer to the word with the caution that it is derogatory and offensive slang.
The saying "The wogs begin at Calais" was originated by George Wigg, Labour MP for Dudley, in 1949. In a parliamentary debate concerning the Burmese, Wigg shouted at the Tory benches, "The Honourable Gentleman and his friends think they are all 'wogs'. Indeed, the Right Honourable Member for Woodford [i.e. Winston Churchill] thinks that the 'wogs' begin at Calais." Wigg's coinage, sometimes paraphrased as "Wogs start at the Channel" or "Wogs start at Dover", is used to characterise a stodgy Europhobic viewpoint, and more generally the view that Britain (more so England) is inherently separate from (and superior to) the Continent. In this case, "wog" is used to compare any foreign, non-English person to those more traditionally labeled "wogs".
As a synonym for "illness" in Australian English
Wog was originally used in Australia as a slang term for illnesses such as colds, the flu or malaria. This usage has been in existence since at least the early 1940s. It is recorded in the 1941 Popular Dictionary of Australian Slang by S. J. Baker as meaning a germ or parasite.
A once common expression in Australia when you had an illness (such as cold or flu) was "I am in bed with a wog." It was said jokingly and was a double entendre referring to the use of the word "wog" to describe illness and also persons of Mediterranean origin (as described below).
Another use of the term, which dates from 1909, was to describe insects and grubs, particularly if they were hunting insects or regarded as being unpleasant in some way.
As an ethnic reference in Australian English
Wog is also an ethnic slur in Australian English to denote immigrants of predominately Middle Eastern and eastern or southern European origin.
The "ethnic" character of the term "wog" came into popular use in the 1950s when Australia accepted large numbers of immigrants from Mediterranean/Eastern European countries, in contrast to the then overwhelmingly dominant ethnic white Australian stock of the population. Although originally used pejoratively, the term is increasingly used more affectionately, especially by the individuals the term is used to describe.
The term "wogball" refers to soccer (association football), coming from its popularity among such people. Australians of non-Mediterranean ancestry traditionally favour the games of Rugby football and Australian Rules, although this is a generalisation.
The term was often used in popular Australian comedy Kingswood Country between 1979-84 and was used in a sense that was sometimes pejorative, sometimes affectionate and sometimes neutral.
The word was prominently used in the popular early 1990s stage show Wogs Out of Work, created by Greek-Australian Nick Giannopoulos and Spanish-Australian Simon Palomares. The production was followed on television with Acropolis Now, starring Giannopoulos, Palomares, George Kapiniaris and Mary Coustas, and in film with The Wog Boy.
Nevertheless, the term remains quite offensive to many people in Australia, particularly people of Southeastern European and Eastern European origin who grew up in Australia through the 1950s to 1980s as it was still very much an ethnic slur or insult.
The derogatory nature of the term when used as an ethnic slur largely succeeded in overtaking and driving out use of the term Wog to describe illness or undesirable insects.
Wog is a shortened version of the word pollywog, frequently modified with the word slimy, used for sailors during the Line-crossing ceremony on the first time they cross the equator. Pollywog or polliwog is an increasingly obsolete synonym for tadpole which has been traced back to Middle English.
This use of pollywog goes back to at least the 19th century and thus may be the oldest source of wog, although Eric Partridge missed it in his Dictionary of Slang and Unconventional English (1937).
Maritime wog is a possible alternative ancestor of the racial wog, particularly since Partridge does record a usage for presumably annoying Bengali bureaucrats:
"A lower-class babu shipping-clerk: nautical: late C.19-20" - Concise Dictionary of Slang, Eric Partridge, 1989
As a term in Scientology
Amongst Scientologists, wog is used as a disparaging word for non-scientologists. Scientology's founder L. Ron Hubbard defined wog as a "common, everyday garden-variety humanoid ... He 'is' a body. [He] doesn't know he's there, etc. He isn't there as a spirit at all. He is not operating as a thetan. The term comes from 'Worthy Oriental Gentleman', from the days of the British in Egypt. [sic]"
L. Ron Hubbard employed the term frequently in his lectures and writings.
Since wog is not in general use in American English, it is most likely that Hubbard picked it up during his period of service as a US naval officer during World War II (1941-1945). An alternative source would be England, where he resided 1953-1966.
In Scientology, wog lacks racist overtones, even in the UK where that meaning is prevalent. From a 2004 Church of Scientology magazine: "I arrived at Saint Hill shy, introverted and somewhat out of valence. I had been working at a wog job, and I knew my priorities had to change ..."
As a piping component term
WOG appears on certain types/models of block or check valves, indicating they are suitable for "water-oil-gas" service, where gas normally means natural gas or propane. The letters "WOG" are always in capital letters and are usually raised, having been cast with the valve body. This abbreviation sometimes appears as "W.O.G."
The term wog is often given a folk etymology as an acronym for various phrases:
No evidence has been found for any of these putative explanations. The Western/Westernized/Wild Oriental Gentleman acronym only appeared in the 1950s and 60s, although the term wog had been in use for considerably longer.