First off, please get the new understanding that pain is not simply a brain input; pain is brain output. And there's a difference. This is a deep discussion that we can have, but I'd rather refer you to someone who did a great piece on this (DOCUMENT).
How can food relate to this?
Inflammation is the process that happens when you sprain an ankle. There is a chemical cascade that is set off around and at the damaged tissue, and the end result is redness, swelling, and — you guessed it! — pain.
But, what if I told you that what you eat, your chemical composition, lends itself to someone who is easily inflamed, or someone who is not. (The opposite of inflammation is rest, calm, non-irritated.)
The truth is, you can. This is the secondary link with food intake and pain.
Two Pathways: One is More Painful
Ever wondered how a non-steriodal-anti-inflammatory works? It works by shutting off an enzyme called "COX." NSAID's are called COX-inhibitors. Please look at this picture.
At the top, on the left, is omega 3 fatty acids. On the right is omega 6 fatty acids. You've probably heard a lot of buzz about "taking your omegas," this is one reason why. Your body is made of up tons of fats. In fact, most of the outside lining of cells is made up of this fat. Omega 3's have a tendency to be anti-inflammatory. Omega 6's have a tendency to be inflammatory. Why is this important? Because your body needs a balance of the two. Not too much, not too little.
It has been estimated that the human body is supposed to have a ratio around 1:1 of omega 6's to omega 3's. Most humans nowadays have a ratio closer to 15 - 20: 1. Not 1:1. That tilts the scale heavily in the direction of omega 6 saturation. That means that your cells are made out of the PRO-inflammatory molecules, which means that they are naturally more likely to get inflammed, irritated, and lead to "pain output."
One of the chief fatty acid scientist, William Lands, was frequently hired on as a consultant to pharmaceutical companies who were then just beginning to make the ibuprofens and Aleves that we are so familiar with today.
"...you can change the kind of [inflammation] signaling in your body by changing the kinds of fats that you eat.
... He [Lands] always told the companies that nutrition would regulate the availability of prostaglandins [molecules that signal inflammation] too. And their answer was always the same: There's no way to make money on nutrition. Lands said the same thing about nutrition to john Vane when he met this very famous pharmacologist on a trip to Vienna. "Yes," he remembers Vane replying, "but you can't patent that [nutrition]."" - Queen of Fats. (2006) Susan Allport. pp. 99-100
This same truth is available to you now. Want to stop popping an aspirin every morning before heading to work? Try limiting the inflammatory foods you eat, those foods rich in omega-6 fatty acids. Here is a list (LINK). Then, add an omega-3 supplement to your diet while increasing your food intake of omega-3's (usually fish, sardines being one of the best — I know they smell nasty... think of it like medicine), and see the change in pain.