LCD contrast switcher for 8051
The transistors are unnecessary. The port pins can handle the current of VO directly. Just set them low or hi-z as needed.

If you need more resolution, consider building an R-2R DAC. N outputs will give you 2N different settings.

And LCD modules are very low-power devices overall. Nothing is going to "melt", no matter what you do (within the "Absolute Maximum" ratings, of course).