First you have to use 802.1q trunking on the switchport:

switchport mode trunk
switchport trunk allowed vlan add 1,2

Then you have to configure your NIC to recognize and send tagged packets. On some Broadcom NICs for example you can do this with a windows utility. With Linux you can configure the kernel to support 802.1q and create virtual NICs for each vlan. Can you give some more details about what you want to achieve and what OS?