That’s why it’s important to water the base only, not the foliage and let the soil dry out between watering.
It’s also advisable to plant lavender in a large flowerpot that has a drainage hole and plenty of loose gravel at the bottom in order to improve air flow to the roots and thus prevent rotting. Although the plant is relatively small, it actually has a large root system that can get suffocated if planted in a small pot.
A mix of peat, vermiculite, and perlite is most beneficial for lavender. Regular potting soil will also do.