Obviously, sticking your tongue up another guy's hole puts you at risk of infections. Whether it's "clean" or not doesn't really affect that, it comes with the territory.
Having said that, the most worrying risk is probably Hepatitis B, which can have serious long term effects.
It is possible to be vaccinated against this (in many countries, the vaccination is available for free) and well worth doing. I think it's fair to say that the other things the average Joe might contract from rimming are much less worrisome.
And, yes, rimming someone's who's actually, visibly dirty probably isn't the best idea in the world.