You have not set forth enough facts. This is posted under DUI. Were you charged with DUI? Disorderly conduct? Public drunkeness?
The information provided is for general informational purposes only and is not intended to be legal advice. I am only licensed in the Commonwealth of Pennsylvania and I am not providing you with specific legal advice. The law changes frequently and varies from jurisdiction to jurisdiction. Being general in nature, the information provided may not apply to any specific factual and/or legal set of circumstances and/or the jurisdiction where you reside. No attorney-client relationship is formed nor should any such relationship be implied. The information provided is of a general nature is not intended to substitute for the advice of an attorney, especially an attorney licensed in your jurisdiction. Your question, although you may believe is simple, it is not simple. You require legal advice, please consult with a competent attorney licensed to practice in your jurisdiction.
It is unlawful to obey a reasonable request from a law enforcement officer. In a bar, the officer is well within his rights to ask for ID to establish your legal presence in the premises. If you were indeed driving the same answer applies.
Every legal matter is fact specific, and there are often nuances in every case. This is intended for comment only, and does not create an attorney client relationship.
I believe that you were likely asked for ID to verify your age at a bar. I'm just unsure what the charge would be in your case. Minor attempting to posses alcohol? Anyway, not enough facts here to intelligently answer the question. Although I do believe the cop can ask for you for ID to verify age. Good Luck!