It has been UK law since 2016 for every dog to be identifiable via a microchip. As well as animal charities, who will often chip your dog cheaply or for free, it is a relatively inexpensive procedure at your local vet - costing between £10 - £20. Puppies can usually be microchipped from around the time of their initial vaccinations and many breeder will have it done before a puppy leaves them.
A microchip is a small device, just a little larger than a grain of rice, that is implanted via a needle under your dog's skin around the shoulder blade area. It is a safe procedure. In some dogs it may cause momentary discomfort but Shih Tzu rarely seem to complain any more than they might a routine vaccination. Each microchip has a unique number embedded that it transmits when activated by a scanner. Note that microchips don't have batteries, they are activated by specific radio waves from a scanner. This number is registered to you on a national database along with your contact details so that if your pet is lost or stolen it has a much higher chance of being re-united with you. Obviously it is important you keep this information up to date if you move house.