Pollution caused by the discharge of untreated sewage from aging sewerage systems on St. Thomas [1] and St. Croix causes beach closures on those islands from time to time. The U.S. Virgin Islands Department of Planning and Natural Resources is responsible for testing the water quality of beaches, and for alerting the public if pollution reaches dangerous levels. Beach closures are announced in the local newspapers, and you will be alerted by notices posted around the beach. You can also contact the DPNR at 340/773-1082 on St. Croix or 340/774-3320 on St. Thomas. Results of the weekly water quality testing are also posted on the DPNR website, www.dpnr.gov.vi [2].
In the British Virgin Islands, the authorities are not as fastidious about testing water quality, so use common sense. Popular anchorages, such as Road Harbour, Cane Garden Bay [3], and Trellis Bay, are probably not the cleanest places to swim.
Links:
[1] http://www.moon.com/destinations/virgin-islands/st-thomas
[2] http://www.dpnr.gov.vi
[3] http://www.moon.com/destinations/virgin-islands/tortola/sights/cane-garden-bay