Shampoo contains surfactants, chemicals which cause lipids to emulsify. The cell membrane is composed primarily of phospholipids, which are vulnerable to action by surfactants. In fact, sodium dodecyl sulphate (SDS, often labelled SLS on shampoo bottles), an integral component of many shampoos is also used in the lab (albeit at substantially higher concentration) to achieve cell lysis.
The outer layer of skin is composed largely of a very tough type of cells called keratinocytes, which form an impenetrable barrier to potentially harmful chemicals like surfactants. Once the skin is ruptured, the surfactant can act on cells that don't have the protection of keratin, causing damage to cell membranes, and perhaps even cell death. This will obviously lead to an immune response and inflammation, which is likely to be the source of the burning sensation/pain that one feels.
The inflammatory process involves various immune system-related mediators such as bradykinin and prostaglandins, which act to increase the sensitivity of neurons to pain.
With other chemicals that cause a burning sensation, the mechanism of cell injury might be different, but ultimately, the immune mechanisms kick in, causing inflammation and pain.
Kid & Urban (2001) reviews the processes that cause inflammatory pain in great detail (full text is available for free).