Octopus are intelligent creatures. However, according to this article researchers still don't know how invertebrates and cephalopods interpret 'pain' or even if they feel it. This is an interesting article from The Senate Standing Committee on Legal and Constitutional Affairs from the Parliment of Canada:

Do Invertebrates Feel Pain?

Interesting stuff!