Well, you own the copyright to anything you write and you can specify the terms of use as you see fit... there are licenses which differentiate between commercial and non-commercial use. And GPL-3 has some open source vs closed source implications...