Cook spaghetti according to package directions; drain.
Meanwhile, cook beef and onion in a skillet over medium-heat, stirring until beef crumbles and is no longer pink; drain. Combine pasta, meat mixture, and pasta sauce in a large bowl, toss to combine. Set aside.
Preheat oven to 400 degrees F. Melt butter in a saucepan over medium heat. Stir in flour; cook 1 minute. Gradually whisk in milk; cook 5 minutes or until thickened. Remove from heat; stir in Parmesan cheese, salt, and pepper.
Pour half of spaghetti mixture into a lightly greased 7 x 11 inch baking dish; pour cheese sauce over spaghetti. Sprinkle with 1 cup cheddar cheese. Top with remaining spaghetti mixture, and sprinkle with remaining 1 cup cheddar cheese. Bake at 15 minutes or until cheese melts.