Of course, some things are obvious. If something is clearly spelled out as sin in the Bible, you don’t have to ask if you should do it. For instance, if someone talks about stealing something, you know the answer is “no.”
In cases like that, it may be a temptation that God is allowing into your life to test you. He promises that He will never test you beyond what you are able to handle. And, that He will provide a way out so you don’t have to sin. (1 Corinthians 10: 31.) So, when you are tempted, ask Him for help. Ask Him for that way out. Then, follow Him.
For instance, David had a way out when he saw Bathsheba swimming naked, that night he couldn’t sleep. That way was to go inside and not look at her. When he didn’t, he could have decided not to sleep with her. But, he did. Then, he had to live with the consequences of his sin. She was pregnant.
God still had a way for David to avoid sinning further. He could have confessed. It was the wife of Uriah, a general who was very committed to his job, and to the king. If David had been sincere in his repentance, Uriah may have forgiven him. That means, he would have refused to hold it against David. He and Bathsheba would likely have loved the child and raised him as their own. David would have always wondered if he’d have been a good father to that child. His reputation would have gone downhill.
But, it would have been far better than what happened. He had Uriah killed and married Bathsheba! His whole family was a mess after that. His son, Absalom, even tried to kill him and take over later! When David finally confessed, it was very painful. He had done so much wrong. And yet, God still loved him. What amazing grace!