The US did attack targets in North Vietnam for several years as part of Operation Rolling Thunder and conducted an intense strategic bombing campaign against Hanoi during Operations Linebacker and Linebacker II. Rolling Thunder was somewhat limited in its scope in that cross-border raids were conducted by tactical aircraft (F-105s, A-7s and F-4s being some of the more prominent ones), but Linebacker and Linebacker II were massive escalations with formations of B-52s bombing downtown Hanoi. Linebacker II topped it all off with over 20,000 tons of bombs dropped in just eleven days on Hanoi.
If you're asking as to why the US (or South Vietnam, for that matter) never directly invaded North Vietnam, it's because, oddly enough, the US never actually declared war on North Vietnam. US involvement in the region started under the guise of military advisors and ramped up into what most people would recognize as the Vietnam War as a result of the Gulf of Tonkin Resolution, which authorized the use of military force in Vietnam but wasn't actually a declaration of war. The Johnson Administration was very careful to limit escalation of the conflict, often producing odd situations like the fact that there were tactical bombers conducting strikes on strategic targets in North Vietnam as part of Rolling Thunder while strategic bombers were being used for attacks on tactical targets in South Vietnam under Operation Arc Light. Even with B-52s being used to attack tactical targets, Johnson was very cautious with the strikes, forcing the Air Force to get personal approval from the President for every Arc Light strike.
Johnson's reasons for being so cautious stemmed back to the Korean War. Mainland China was still hostile to the US, and while they were on less friendly terms with the Soviets (and thus the Soviet-backed North Vietnam) than they were in previous years, there was still the very real fear that an invasion of North Vietnam would result in a repeat of the Korean War, where Communist China would intervene to prevent a total victory for anticommunist forces. With that in mind, Johnson was cautious to not escalate the war in such a way that the Chinese would feel the need to intervene - hence the absurdity of the Arc Light strikes.