If you go up to a police officer and swear at her she will warn you not to, and if you do it again she will probably arrest you under Section 5 of the Public Order Act 1986. The law is that if you use ‘threatening, abusive or insulting words…which are likely to cause harassment alarm or distress to a person of reasonable firmess’ you have committed an offence. Police officers are rightly taken to have more ‘firmness’ than most people, so are less likely to be harassed alarmed or distressed. But the High Court held in 2007 that there is no rule of law that the offence cannot be made out when the only person who heard the words in question was a police officer (Southard v DPP). Bear in mind the words ‘likely to': you don’t have to intend to harass alarm or distress anyone. The Magistrates who try you will look at the circumstances and decide, objectively, whether your words made that outcome likely.
It won’t help if you tell the officer or the beak that you read on Twitter or in the Daily Telegraph that swearing at the police is OK. They will think you are an ignorant smartarse.
PS The Home Office have published a consultation paper about doing away with ‘insulting words’ as part of the Section 5 offence: http://www.homeoffice.gov.uk/publications/about-us/consultations/police-powers/consultation-document?view=Binary