It's only a habit you need to break now if it bothers you to do it. I think learning to fall asleep by yourself is a good skill, and 5 months is a fine time to teach that. Here's what I'd probably suggest if you DO want to do this:
Instead of nursing your baby to sleep last-thing, try nursing him a little earlier - maybe right before his bath instead of afterwards, or keep him awake afterwards for a little bit. Basically, you want him sleepy but not asleep when you put him down. Then you can pat his stomach, tuck him in, sing to him etc. The key is that he can fall asleep while he's laying down, and NOT while he's nursing.
That said, when you feed him during the night I (obviously) wouldn't worry about him falling asleep while nursing - that's your cue to unlatch him and lay him back down to sleep. :)