Social group size, mating systems and sex allocation strategies in fish can covary with habitat patch size. We examined the interrelationships of these factors in the seawhip goby, Bryaninops yongei, which inhabits just one species of seawhip, Cirripathes anguina. Above a critical length, a single immature fish mostly occupied small seawhips. Larger seawhips were mostly occupied by an adult pair, with almost 100% occupancy of seawhips greater than 200 cm long. Larger social groups were occasionally observed, but there were never more than two adults in these groups. Therefore, habitat size appears to have a weak effect on social group size, but does not affect the mating system of B. yongei. Histological examination of the gonads from 50 social groups confirmed that adult pairs always consisted of a functional female and a functional male, indicating a probable monogamous mating system. Gonadal structure also indicated the capacity for bidirectional sex change. Adult females contained a precursory accessory gonadal structure, which is a good predictor of female-male sex change in gobies. Adult male gonads contained an inactive ovarian zone next to the active testicular zone, as seen in other gobies capable of male-female sex change. The similarity in the mating system and sex allocation strategies of B. yongei and other coral-dwelling gobies indicates that the reliance on small, patchily distributed habitats has been important in the evolution of pair forming in conjunction with labile sex allocation in these fish.