There are a number of tests and the Inland Revenue website has details. The basic rule is whether it's a contract 'of service' i.e. you've got to do as you're told, or a contract 'for services' i.e. you can deliver the service, within reasonable limits, how and when you want to. Employment law and tax law can vary a little but it's a good staring point.