How do we know when to test if the user drunk?
An app that requires a test before you can use it at start up will be so frustrating you'll stop using it immediately, well intentioned or not. A schedule system would allow users to specify when they wish to be tested (e.g. I might be drunk after 8 PM on fridays and saturdays). Most importantly, this could allow you to have an app that blocks other apps based on a schedule; rather than building this feature into a single app, one could have an app that blocks texting, email or calls, rather than requiring the user to use your proprietary app. (this has implementation due to access rights, but is a possible feature)
How do we know you're drunk?
Speech recognition is an advanced possiblity. Computer analysis is now possible which can detect slurred speech. This will likely work for a majority of users, but it's important to consider users may be mute or may be using their phone where speaking aloud would be inappropriate; while a nice feature it should not be the only way to test drunken users.
The easy software solution would be an integrated breathalyzer; this of course requires specialized hardware, but isn't completely infeasable; these devices are cheap and could be a peripheral or built into a handset from the get go.
Barring speech recognition and specialized hardware, a motor skill and or reaction time test is the common solution; alcohol significantly impairs task performance. Allow a user to set a baseline performance (to accommodate users with better or worse motor control/reaction times than typical) and give them a test. Common motor skill tests could be simple commands like "tap here" on a touch enabled device or a typing test.
Asking a user to set a "drunk baseline" would be a very bad idea; never encourage irresponsible behavior.
What do we do if they're drunk?
Give the user several tries to retry. I would hesitate to ever implement a "lockout" that prevents future tries. You could leave a lockout or timeout feature as a configurable option; users with poor motor skills will want it off, but, ahem, "power users" of alcohol might want the extra security a lockout provides.