I was diagnosed with pyogenic granuloma under my toe nail, I removed it by electrocautering, for how many days should I feel pain after the operation?

Depends. On your pain threshold. Normally tender to touch or in closed, tighter shoes for about a week. May be longer depending on how much of the nail bed has been involved. Nail bed has to harden so it is not so sensitive to touch.
Cauterizing. A pyogenic granuloma may typically hurt on contact or for a little bit of time afterwards. It should not be hurting "days later". If the toenail was avulsed - this may cause pain/discomfort for few days. Look for signs of infection, if pain persists inform your doc.