Contact the recruiter you worked with at that company and advise them that due to an unforeseen change in personal circumstances, you're unable to resume the opportunity at this point. Do thank them for their time and effort in considering your candidacy and offer to help them find an equally good referral (if you have one, if not that's ok too).
Do the same with the hiring manager.
However, be sure that you truly want to take up offer B before doing so.
The best approach, of course, is to avoid being in this situation as best as possible by delaying acceptance (especially when competing offers are expected) in the first place.