If you get enough links from those blogs it will help you to improve your placement in the serps even if it's not related to your site.
No penalty for commenting on a blog not related to your niche. You have the right to comment on any blog you want. As zzxxcc said, there's nothing wrong with commenting on a friends blog or something you find interesting, that's only natural. You will likely not see any ranking boost from this link but it shouldn't hurt you. What is more likely to get you punished would be leaving thousands of comments on thousands of unrelated blogs in a very short amount of time. That has the potential to cause harm. Google looks for linking patterns that appear unnatural or abnormal.
Of course you won't be punished by Google. What for? Google don't penalize sites for external factors that nobody can control (most of the times). However don't expect to see great results from blog commenting, especially if you're in a highly competitive niche.