The substitutional effects of cobalt in (Fe1-xCox)5PB2 have been studied with respect to crystalline structure and chemical order with X-ray diffraction and Mössbauer spectroscopy. The magnetic properties have been determined from magnetic measurements, and density functional theory calculations have been performed for the magnetic properties of both the end compounds, as well as the chemically disordered intermediate compounds. The crystal structure of (Fe1-xCox)5PB2 is tetragonal (space group I4/mcm) with two different metal sites, with a preference for cobalt atoms in the M(2) position (4c) at higher cobalt contents. The substitution also affects the magnetic properties with a decrease of the Curie temperature (TC) with increasing cobalt content, from 622 to 152 K for Fe5PB2 and (Fe0.3Co0.7)5PB2, respectively. Thus, the Curie temperature is dependent on composition, and it is possible to tune TC to a temperature near room temperature, which is one prerequisite for magnetic cooling materials.