Placing links in guestbooks is very annoying to their owners, and will rarely give spammers any long-term benefits, as their owners tend to quickly delete comments that are suspicious looking. A lot of guestbooks also uses nofollow on links that are placed by visitors, in an attempt to discourage spam.
Placing links in comments with the intention to manipulate your own placement in the SERPs is a blackhat technique! This does not mean however, that you should stop linking to your site when commenting.
Rather than than placing links, you may want to make sure that you have done enough on-site optimization. For most sites, this is not the case, and their owners usually have a poor understanding of content quality.