Congrats on wanting to make sure you’re healthy. This is a common question. Sometimes your foreskin can go back (or retract) on its own when you have an erection. If it does not, it is important to make sure that it you can gently retract it to the bottom of your penis (end closer to your scrotum). If you can retract, great! If you cannot gently retract it, we recommend talking to your healthcare provider about things you can do, such as using a cream.
Also, you may be wondering about condom use to prevent sexually transmitted infections and pregnancy (if having vaginal sex). The Center for Disease control recommends gently pulling back your foreskin before putting a condom on an erect penis.