Normally, when something touch you, you won't feel pain. With a great force "touching" you, you will feel pain. However, if something that is spiky makes contact with you, you will feel pain. So, how much force should be exerted by a smooth/blunt object to make you feel pain? When and how does a spiky object make you feel pain?
It is a simple matter of biology and physics actually:
Firstly, pain is caused by the simulation of cutaneous nociceptors in the body, beneath the skin and are activated when the sensation crosses a threshold.
Nociception (also nocioception or nociperception) is the encoding and processing of harmful stimuli in the nervous system, and, therefore, the ability of a body to sense potential harm. It is the afferent activity in the peripheral and central nervous systems produced by stimulation of specialized free nerve endings called nociceptors or "pain receptors" that only respond to tissue damage caused by intense chemical (e.g., chilli powder in the eyes), mechanical (e.g., pinching, crushing) or thermal (heat and cold) stimulation. Once stimulated, a nociceptor sends a signal along a chain of nerve fibers via the spinal cord to the brain. Nociception triggers a variety of autonomic responses and may also result in a subjective experience of pain in sentient beings. Nociceptive neurons generate trains of action potentials in response to intense stimuli, and the frequency of firing determines the intensity of the pain.
From the wiki: https://en.wikipedia.org/wiki/Nociception
Now when you consider a knife, the surface area of the knife is small enough that it can cause damage. It's akin to holding a plastic sheet stretched tight and then piercing the sheet with the point of a knife. That is because the force is being transferred on a small point and hence easily extends the pain threshold.
However, when you consider a hammer, when the hammer touches you (lightly) you don't feel the pain because the force is spread over the larger surface area of the hammer and hence doesn't meet the threshold. However, if you hammer your finger in with force, the force being transferred is enough to shatter your bones, and in that case not only the cutaneous pain receptors activate, but the somatic receptors also activate, causing the feeling of pain.
TLDR: Knife has short surface area, and hence force transfer is over a small area, subsequently causing hurt. A hammer has a larger surface area, and hence unless more force is applied, the pain receptor threshold is not met and hence no pain.