The argument goes something like this:
"If we're going to hand out 'free' taxpayer money (welfare) to poor people we shouldn't be rewarding drug-heads."
So, from this there seems to be two main conjectures:
1. We hand out "free money" to some people at the expense of others.
2. Drug use should be punished.
Let's first consider what welfare is and isn't. Prima facie, welfare (in its various forms) seems like direct subsidization of a particular group (the poor) for a particular reason (poverty). I think this is partially right, but still somewhat misleading. Welfare is actually something much more like mandatory, public poverty-insurance. Now, you can make the argument that you're against being forced into such a program - in fact, I make that argument quite regularly. But once you've been coerced into it, it's not quite clear why the use or non-use of recreational substances should have anything to do with your eligibility as a recipient in such a program.
Take, for example, health insurance; everyone pays, collectively, into these plans that essentially pool the risk of anything requiring medical treatment. People who find themselves in need of an important treatment or operation are not simply getting handouts from other plan participants through their payer...they are simply collecting on the bet that they hedged in the first place. If, collectively, we want to restrict such payouts (which obviously makes sense on a certain level), we would focus particularly on fraudulent claims or risk-ridden actors.
In the case of health insurance it means systematically restricting claims for charges that are (hypothetically) uncalled for. It could mean price-adjustment for premiums from more medically risky participants. Essentially it would revolve around what they are insuring against. In regards to welfare programs, we're talking about insuring against poverty itself.
At this point, there are two breakaway arguments on behalf of mandatory drug-testing, each with different implications.
The Practical Argument
"If they can afford drugs then they don't need the handout."
This makes sense as far as it goes The problem here is that it's not clear why drugs are singled out for concern. If you're insuring against a given condition (in this case poverty) then any series of bars or qualifications would seem to revolve around a particular actor's ability and circumstance...which would suggest, possibly, a strong form of means-testing for qualification. Whether you're able to somehow find enough money for $500 worth of drugs every month or $500 worth of troll dolls isn't really of import in that sense. The important part would be that you have $500 tucked into your monthly discretionary spending. Means testing can, again hypothetically, account for this. If you're trying to reduce fraudulent welfare claims by singling out drug-users then you're likely missing a good deal of the problem altogether.
The Punitive Argument
"Drug use is illegal and should be punished."
I think a good debate could be had on this as there's plenty of room to contest how we look at the War on Drugs in America. I still think it largely misses the point. Society already seems to largely agree on this, which is why we have a plethora of criminal laws aimed at stifling such behavior (much to my discontent). It's already illegal (and punishable) to use most recreational substances. If you're not sure exactly how seriously our system takes it, then you haven't been paying attention.
But why are we arbitrarily singling out welfare as the one public good for which we must prove we're not committing some particular crime before we may receive it? If someone is driving recklessly or under the influence surely that in itself is a legal infraction - as would be the case if a welfare recipient got drunk and punched someone. Few people are arguing against either of those conjectures. Yet we don't insist that you get tested when you receive your licence...or every time you get in the car. Why would we demand to test you for drugs then when receiving what amounts to an insurance claim?
What other public goods and services should we make contingent on drug-use? Roads? Parks? Police? Firefighters? Courts? The military? Why the push, specifically, on social insurance? Even if we make the argument that using illicit substances necessarily keeps you in a situation where you will draw excessively on such a public good (which is a dubious claim to begin with), could we not use the same argument with regards to courts or the police, and demand periodic warrantless searches on behalf of the taxpayer(s)?
In a world absent such coercive programs, where individuals could employ the services of co-op or for-profit providers of said goods and services, people could choose what kind of structural implementation(s) they'd like to participate in. But to the extent that we are quite literally forced to participate in such programs, keeping irrelevant behavioral discrimination to a minimum has to be a priority - particularly if you are critical of such programs, as they exist, to begin with. The extent to which public goods and services play a role in our lives is the extent to which the state may curtail individual liberty. If only the supposed "small-government" types were as keen in seeing the danger of control with publicly-held social insurance as they were in seeing the danger of control with publicly-held health insurance. They'll shit a brick about a hypothetical situation where a single-payer system won't pay for their heart-operation because they eat Cheetos, but don't blink an eye at the thought of a single mother and her kids going hungry because she decided to smoke a doobie once or twice.
If you think that's apples and oranges - you're wrong.