The Scottish Charity regulator said St Margaret's Children and Family Care Society provides a valuable service.
But the watchdog said it believed its current practice was unlawful. It has now given the society three months to change its procedures.
The Glasgow charity said it was talking to legal advisors about the matter.
The ruling from the regulator follows a complaint from the National Secular Society about St Margaret's statement that it would place children with parents who have been married for at least two years.
'Duty to act'
The Scottish Charity Regulator's head of registration, Martin Tyson, said: 'We acknowledge the valuable service provided by this charity, but the fact is that all charities must comply with the law, including the Equality Act 2010.
"Where we find this is not the case, we have a duty to act.
'We have carefully considered the details of this case, and the legal position is clear - the charity must take steps so that it does not discriminate unlawfully and can pass the charity test."
He said this was a "complex" case and the regulator had "discussed matters at great length with the charity's trustees".
Mr Tyson added: "We hope that the charity will respond positively and take the necessary action so that it remains in the Scottish Charity Register."
The regulator has issued a direction to St Margaret's, instructing it to amend its procedures and assessment criteria to meet the requirements of the Equality Act.