Here’s a remedy that’s been known to quickly solve a developing knee problem:
If the pain is in the front of the knee, raise the saddle. If it’s behind the knee, lower the saddle. Start with just 2-3 millimeters. Don’t go overboard with big adjustments all at once.
If the pain at the front of the persists, it could be that your crank arms are too long and you are on your way to knee damage. See a bike fitter that knows how to calculate the correct crank length for you. Knee pain is not something to mess around with.