There are two ways in which it is used:
One of the earliest examples of its public use is in a photograph of Jim Horne, a model, whose use typified the "disgust" aspect.
An example of its use in popular culture is seen in Star Trek: The Next Generation, where Jean-Luc Picard more than once expresses disbelief using this gesture. Captioned pictures of such images are a frequent internet meme.
A similar expression, usually used only online, is "headdesk", as in the person banging their head against their desk in frustration.