Make sure you prime your eye with something (if you don’t have an eye primer, apply foundation and powder to your eyelids), and once you’ve applied your pencil, use a powder eyeshadow over the top to set it. You can use shadow in the same colour if you want to keep it dark, or you can experiment with lighter colours to see the effects they give over the black.
If it’s under your eye, try to avoid greasy eye creams, as they can make smudging worse. I find that liner under my eyes always smudges unless it’s waterproof and set with a powder. Hope that helps. :o)