Have someone such as a Piano teacher or advanced player check your technique. You may be playing in a way that is causing harm to your finger. If you don't have a teacher or advanced player you can reach out to you might try posting a video of your playing to get advise on your technique.
If the pain continues or happens when you do other things, seek medical advise. I have Psoriatic arthritis that started as a pain in a single finger joint. Finger and joint pain shouldn't be taken lightly, especially for a musician. It is important to get diagnosed and start treatment as soon as possible if it is a condition that will affect your finger mobility.
I had similar pain in my right finger and it turned out to be something called "Trigger finger" which as a guitar player, caused pain when playing.
The pain usually starts at the bottom of the finger, but can cause knuckle movement to cause pain elsewhere in the finger.
I eventually had to to get surgery called "Trigger finger release" which opens up the bottom sheath around the tendon. Left unchecked, it gets worse over time, but the surgery for me worked. Best thing to do is ask your Doc what they think. Bottom line is don't ignore it.