Prescription drugs are an unfortunate target of both theft and children's curiosity. Thousands of kids die each year from unintentional poisoning. Prescription drug abuse is a growing problem in our schools and among teens and young adults. Even invited guests are often curious as to the contents of your medicine cabinet. For that reason, the medicine cabinet is probably a poor choice for storage of potentially dangerous drugs (even over the counter drugs can be harmful or fatal when misused). In some instances, such as when you are selling your home, your home may be accessed by relative strangers who would be relatively free to look around your home.
There are several options. Lock boxes designed to fit medicine cabinets are available, though are easy to carry off. An economical choice would be to use a small safe like the many fireproof safes available to protect important papers, though these can be carried off as well, if not secured in some way. These locking fireproof boxes offer only minimal resistance to unauthorized opening, but are far better than an unlocked cabinet. Burglary-rated safes are ideal, though more costly.
Another possibility, depending on the design of the medicine cabinet, is to have a lock installed on the cabinet itself. Again, the design of most cabinets would make it susceptible to opening by force, but evidence of the intrusion would be obvious, and it would deter most curious kids. As with any locking device, don't leave the key in or near the lock.