If I experience flank pain, how should I treat it?

Depends. Flank pain can be from various things. Could be muscle strain or ache, and benefit from rest, heat and ibuprofen. Less commonly could be sign of kidney infection, especially if accompanied by urinary symptoms, or possibly kidney stone. Renal pain is usually very severe, and often moves down into the groin.
Flank pain. It depends on the cause of the flank pain. It could be a kidney infection or a kidney stone so i would get evaluated first to find the cause so then you can treat it appropriately.