There are at least two possibilities. The first would be that when the Scriptures say he put them away, it might be referring to Asa's actual implementation of the prescribed Levitical punishment.
Another way to look at it is to divide the two statements. Asa did what was right in the eyes of the Lord, as David his father had done. He served the Lord with his whole heart and ruled with integrity. Then the writer goes on to indicate one of the other things he did, that is, to put away the male cult prostitutes.
If he did not implement the prescribed Levitical punishment, then he exhibited mercy, but still prevented the practice from continuing in Israel. Was it the letter of the law? No. Would he have been justified in God's sight if he had carried out the prescribed punishment? Yes. (Again, he may have actually carried out the prescribed punishment.)
However, even if he implemented a lesser sentence than what was prescribed, it's only a difference between prescription and practice. The prescription is not contradicted just because one person doesn't follow it.
He may have partially failed in this, but still overall did what was right in the eyes of the Lord. David himself committed adultery and murder, but he is still called a man after God's own heart--not because he never sinned, but that he repented greatly whenever he did and truly sought the Lord with all his heart.