It is common for woman to experience constipation for few weeks following the delivery.
The pain you feel during defecation is probably because of hemorrhoids or anal tears you have developed because of straining to pass the stool.
Since you have this problem for longer time, it might result from you avoiding the urge to have a bowel movement because it causes you significant pain, or, because you may developed rectocele during the childbirth.
Rectocele (the front wall of the rectum bulge into the vagina) is a side effect of the baby delivery and one of the symptoms that results from rectocele is constipation.
Visit your physician!