That's inflammation and strain of the intercostal muscles between the ribs. It can linger a good while because you obviously cannot stop breathing while they heal. As with other muscle strains and sprains, the best initial treatment is ice -- 20 on and 20 off, then heat after a couple of days, with analgesics. As for medical treatment, that's about
what they would tell you too . . . mostly it's a matter of time, avoiding wrenching or straining movements, no heavy lifting, etc.