How does natural selection affect behavior?
In a population, individuals show different behaviour. In most of the scientific experiments, individuals are separated in two categories : shy or bold.
These two have there advantages and inconvenients : usually, bold individuals have a better access to ressources and mates, but are also more vulnerable to predation (it is the opposite for shy individuals).
Some studies (This one for example) suggest that behaviour is related to growth and metabolism. A fast growing individual would tend to be bolder because it needs to acquire more energy to sustain its metabolism.
This also suggest that behaviour is heritable by the way of the metabolism. As a matter of fact, if a selective pressure is favourable to bold individuals for example, it will favour high metabolisms. In the end, the trait 'high metabolism' will have more chances to be transmitted, as well as the behavior associated with.
If you want to dig up a bit more, have a look at this publication and its references. It is about the effects of human selection (angling) on fish behavior. The basic mechanisms are the same as natural selection.
Individuals can also learn and modify their behavior, so that they can escape the selective pressure. For example, it has been shown that red deer shift their use of the habitat at the onset of the hunting season, to avoid hunting pressure (see here).