I don't know PA law, but I doubt that there is a law that states that if you are buying a house you can break your lease with no repercussions. That wouldn't be fair to the landlord, would it? You get all of the benefits of a lease, but can just walk out on your part of the bargain.
Maybe your security deposit plus "last month's rent paid when we moved in can these just take care of those extra two months so we don't have to pay anything extra"?
Maybe, but only with your landlord's consent. After all, the security deposit's purpose was to cover any expenses due to damage and cleaning, in addition to unpaid rent. The intention when you gave the deposit is that the landlord could hold it until after you have left, so that he could have it available to use for rent, cleaning and repairs.
Last month's rent should cover July's rent, and the landlord should not disagree with that. But you are not allowed to allocate security deposit for rent without landlord's consent. Talk to him about it. Maybe you can work something out.