There is a duty to give ID when you are involved in an illegal act- which is having sex in public.
No, there is not. In many states, you may be required by an officer to identify yourself in such circumstances, but that just means that you have to give your name, and in some states, your address. It does not mean that an officer can (legally) require you to show an ID card. The Supreme Court ruled on that quite some time ago. There is no requirement to carry an ID in this country — outside of when driving, etc. — so obviously there can be no requirement to show ID.