The dosage needing to help treat your pain really depends on how severe it is. If it's something like a bad headache, take a large dose since it's serious pain but (usually) isn't continuous. If it's instead chronic that lasts throughout the day like arthritis or back pain, take lower more frequent doses. You'll likely just have to play around with it a bit to see what works best for you.
Even though the euphoric, energizing, and most other effects from kratom lasts a few hours, the painkilling effects can linger for much longer. When these effects do wear off, it will be slow and gradual. I can get 6- 8+ hours from what is a little over $1 worth of kratom.