It is not related to HPV at all.
Bacterial vaginosis is caused by baceteria, and HPV is a virus - human papillomavirus.
BV can happen anytime the naturally occurring bacteria in the vagina get out of balance.
That can be caused by bathing, soaps, semen (it is alkaline and the vagina is acidic).
It is detected by a medical test, although women who've had it know the signs right away.
Harsh antibiotics can be used, though risks and benefits have to be considered.
Douching with hydrogen peroxide is also highly effective.
I know it sounds weird but it works and there is science behind it.