According to wikipedia, physicalism is now-a-days the preferred term to materialism in order to better include physical phenomenon which might be considered immaterial, e.g., fields or space itself. I'm not sure how important this distinction is, but it does help to emphasize:
- That the physical world contains many complex phenomenon that are not, at least at first glance, material things.
- The central conceit of a materialist position, namely, monism.
In context, monism is the belief that everything has the same fundamental ground, the material universe (or multiverse, depending on whatever theory-of-everything physical you find most appealing). Everything that is real is physical. Philosophy of mind wise, this contrasts with dualism, which asserts that the mind is a real thing which might have a dependence on something physical, but is really more than the sum of its material parts (this is a point where a distinction between physical and material might be worth consideration).
With regard to phenomenon such as pleasure and pain, it is already well established, that, e.g., someone can attach a bunch of electrodes to your head and identify, physically, which parts of your brain (which is material) light up in response to various stimuli. However, this is still not really enough to confirm that the mind is still just a physical entity (like the earth's electromagnetic or gravitational field); to do this we would need a clear chain of causality derived from physical laws, taking us all the way to a definitive description of all the contents of consciousness.
A monist materialist would say we simply don't have the science or technology to do that yet, but there is still no reason to believe it is not possible in theory. A dualist would say we never will because the contents of consciousness are apprehendable only in terms of consciousness itself (or perhaps, some special realm of which consciousness is a part).
Note that dualism thus depends on something other than the physical to explain the nature and workings of consciousness. This shifts the burden of proof in a very awkward direction, and a monist materialist objection might be that no such realm is necessary and that asserting one prematurely is a violation of Occam's razor; when you unnecessarily multiply the number of entities "required" to explain some phenomenon, you might as well so multiply them any number of times (i.e., this manner of thinking allows you to claim equal validity for anything you want).
Getting to the point then, for a monist materialist (e.g., yours truly):
What accounts for pleasure and pain?
The mind does.1 Although conceptualizing the mind as a complex physical entity may require quite a number of _________ blanks, it is not (or should not be) that difficult.
Keep in mind (pun) that the difference between the physical and the metaphysical (required by dualism, but not monism) is not the same as the difference between the map and the territory, although I think it is commonly misconceived or misrepresented that way. Of course the map isn't the territory, but both the map and the territory are still just physical. Likewise, I could give you a physical description of yellow and you could say, "Oh that's not yellow to me, yellow is yellow", asserting that explaining color in terms of wavelength does not capture the experience of seeing it. This is true, but it does not mean the experience of seeing color is non-physical (although you will find piles and piles and piles of philosophical literature trying to insist something like that). It means the map is not the territory.
So too the (really, very physical seeming) experience of pleasure and pain. Since there are many other products of the mind that can be easily replicated via physical stimulus (a material change in the brain that might be mapped to the production of entities in the mind), more abstract phenomenon such as the experience of love and hate might easily be physical events in consciousness stimulated by the (physical) activities of consciousness itself. In other words, consciousness, as a physical thing, may affect itself physically.
1. I'm using "mind" and "consciousness" here interchangeably. More precisely I'd say the former encompasses the latter, but in any case, by mind I do not mean a topic for metaphysical inquiry.