Any motorcycle first used on or after the 1st April 1983 must have an exhaust pipe complying with Construction and Use Regulation 57 and the EC directives which form the basis of the regulations.
Usually it is easy to comply as legal exhausts are stamped with confirmation that they conform to the regulations. Even if the exhaust pipe complies with the regulations, if you alter the exhaust system to make it noisier you will be committing an offence. The full rules are laid down in the Motorcycle Silencer and Exhaust Systems Regulations 1995.
It is an offence for any person to supply, offer or agree to supply a silencer for motorcycle, motor scooter or moped use unless it meets with the standards of the EC Directive or the British Standard or it is marked not for road use or words to that effect, or is marked pre-1985 motorcycle only.
Changes to the exhaust system can affect performance. If you change the performance of your motorcycle without informing your insurance company you may invalidate your insurance, in which case you may be prosecuted for driving without insurance as well.