How do I refuse to work on military-focused contracts?
This answer is for the US, based on my experience with US admissions.
I would say that this is generally not an applications/admissions question, only because it's unlikely to be meaningful to admissions committees. Many graduate departments in computer science work on a cohort-admissions model, where a group of students are admitted each year and then are expected to find a faculty adviser once accepted. In this model it is up to you to find a research program that personally motivates you and then to persuade an adviser to take you on. It is at this stage that you would (and should) make it clear to a potential adviser that you're not willing to work on defense related projects. However, at this point it's probably moot because you're going to be talking to potential advisers based on your perceived compatibility.
What might be a better thing to do during the application process is to ask whether a candidate department conducts any defense related research. Then you can just not apply to defense-related organizations rather than make it a point of contention with programs that you're interested in. Additionally, most CS research is not defense related, and most all broad-based research departments will have plenty of research opportunities that are not defense projects. Consider that about 60% of US PhD students in Computer Science are foreign nationals and ineligible for this kind of work anyway. You will have no problem finding non-military projects to work on.
Some places are well-known as defense-related institutions- for example the MIT Lincoln Laboratory, the Naval Research Laboratory, or the Johns Hopkins Applied Physics Laboratory. It is usually obvious from these organization's websites that this is a focus of theirs, and you can just avoid them. However, if you wanted to apply to a place such as this I would definitely discuss your personal ethics eariler rather than later, and your ethics definitely don't disqualify you. These labs do a lot of research that is "defense-related" in the sense that it provides for the common defense of the country, not because it's a military project. They work on everything from actual weapons systems to civil defense projects like weather satellites, making the energy grid more robust, and information security.
You may lose a position, but be open about not wanting to work for defense-oriented projects. Don't hide it, you do not gain anything by that (as mentioned above in the comments). Some people may not want to work with a "picky" person, anyway, so you do not lose anything, but it is better than unsaid suspicions about why you would not get clearance.
Some bosses may have understanding and offer you non-defense-based contracts, but you need to decide beforehand whether you are happy to work in a group with mixed funding sources, where, while you won't, others may be funded by defense contracts. Some academics will welcome your attitude. It is an idea to check on the websites of your prospective employers for hints of whether the funding sources are mixed, or whether the academics possibly even explicitly avoid defense funding.
Ben Kuipers, a Michigan faculty member that does not take military money, has some advice on this topic in "Why don't I take military funding?":
...there are plenty of options for supporting yourself through graduate school without military funding. You can be a teaching assistant; you can be a research assistant to a faculty member with other kinds of funding; you can find work maintaining computers for a lab in another department; you can get a part-time outside job; and so on. Generally, rejecting the single largest funder will require you to be more creative about looking at other funding possibilities. This creativity will serve you well. One of the fortunate things about working in computer science is that you have a practical skill that is needed by people in many different areas, and they are often willing to pay for your services....
On finding faculty with similar beliefs, I would suggest just asking. A quick scan of each faculty member's web page, and especially the acknowledgements on publications, will tell you where they get their funding. Find a few people whose research you find attractive who have non-military funding, and talk to them.
Personally, I find it most productive to be clear and straight-forward, without being judgmental or confrontational. You will very likely find plenty of people who are very sympathetic to your values, but who aren't willing to make what they perceive as too large a sacrifice. In my personal opinion, it is more important to encourage people to see their choice of work, how it's funded, and what it's used for as an important moral decision that must reflect their own fundamental values, than to pressure them to make the same moral decisions that I have.