Most tenants have the legal right to sublet
Even though the average tenant is legally allowed to sublet, you still have to ask for formal permission. Send your landlord a letter by certified mail, or with a return-receipt requested, that outlines the term of the sublet, information about your proposed subtenant, and any other details of the arrangement.
Your landlord must have a reasonable explanation for denying your request (if your proposed subtenant is unemployed, has poor credit, or has a criminal record, you may be out of luck). If your landlord withholds consent without a valid reason, however, or fails to respond within the application window -- 10 days to request additional information and 30 to approve or reject your proposal -- you can proceed with the sublet.
Still, there are exceptions...
If you live in a rent-controlled apartment, you do not have the right to sublet your apartment. Residents in public housing or subsidized housing (Section 8, for example) should check the individual program’s rules, and may need legal counsel before subletting. Residents of both co-ops and condominiums are often subject to exclusive bylaws or the terms of their lease -- you may be able to sublet, but it’s not a legally protected right.