Had you been on this medication before? (Asks about a past time. At some time in the past, had you taken this medication before that time?)
Have you been on this medication before? (Asks about now. Now, have you taken this medication before now?)
Both of these are correct and natural but have different meanings.