Going off to serve your country is an honor and a great responsibility, but also a lot of work. You will need to make arrangements to put your civilian life on hold, most likely including moving out of your apartment – which might worry you if you have a lease agreement. Federal law explicitly provides that you can usually terminate your lease lawfully.
TL;DR (Too Long; Didn't Read)
If you join the Army, you can break your lease agreement under the following circumstances: being called for active duty for the first time or being called to a change of station that will last 90 days or more.
Getting Out of the Lease
Many laws over the years have aimed to help U.S. members of the armed services shoulder the burdens of their commitment. The Servicemembers Civil Relief Act of 2003, called the SCRA, expressly allows for you to terminate your lease if you are entering active duty for the first time, or if you are already on active duty and receive orders for a permanent change of station for 90 days or more. Activated reservists and members of the National Guard may also terminate their leases. It also applies to all real property leases, not just residential leases.
Your Credit Won't Be Affected
Ending your lease under the terms of the SCRA is not "breaking" it in the sense of violating its terms. The SCRA supersedes the lease and allows you to lawfully terminate it. This means your housing and credit history will not suffer any adverse impact, although you may need to explain to future prospective landlords why you moved out of a residence before your lease's scheduled expiration.
Procedures to Follow
If you do decide to terminate your lease, you must follow a specific procedure. First, you have to give notice of lease termination. The lease then terminates "30 days after the first date on which the next rental payment is due." This usually means that you continue to rent for the rest of the current month and all of the next month, and then the lease terminates on the first day of the month after that, So, if you give notice in July, the lease ends on September 1. You must provide notice of your lease termination in writing, including a copy of your military orders, and the SCRA specifies that you must deliver the notice "by hand, private business carrier, or mailed, return receipt requested, to the address designated by the landlord."
Other Options to Consider
As an alternative to terminating your lease, you can try to spare your landlord some trouble by asking about subletting or assigning your lease to someone else. When you sublet your lease, you remain on the hook for ultimately upholding the terms of the lease if the sublessee fails to pay rent or otherwise does not uphold the lease, so this isn't a good option unless you firmly trust the person. With lease assignment, you completely transfer the legal responsibilities and rights of your role as lessee to another person, meaning you won't have to worry about any hassle down the line.