Even though bacterial vaginosis is not considered a sexually transmitted disease you can acquire it sexually.
You can easily acquire the infection from a new sexual partner(s) and from an old sexual partner who may have been promiscuous behind your back. Other risk factors for bacterial vaginosis include wearing an IUD, excess douching and recent antibiotic use.
Some women develop the infection without any of the above risk factors- this is called bad luck.