Well, you have to first setup the subdomain with you registrar. I use registerfly for all of my domains, and they have an interface that makes it really easy to do so. Second, you have to setup your webserver to recognize the domain, and send you to the right place. I use virtual hosts in apache. It's pretty simple to setup, you basically just specify the hostname (subdomain.domain.tld), and the documentroot for it.
Here is a vhost example from my httpd.conf file:
<VirtualHost *>
ServerName www.gagon.net
DocumentRoot c:/apache/htdocs
</VirtualHost>
<VirtualHost *>
ServerName brad.gagon.net
DocumentRoot c:/apache/htdocs/brad
</VirtualHost>
You also need to include this line somewhere in the httpd.conf file to get apache to use name based vhosts: NameVirtualHost *