It's actually prescribed for that: https://www.nhs.uk/medicines/peppermint-oil/