You can do both. Weight loss or gaining is primarily caused by the number of calories you eat during the day – you can eat 2000 calories of pasta and sauce or 2000 calories of jello and you should stay at the same weight you are (provided you are an average sized person). If you eat more than 2000, you’ll gain weight, if you eat less, you’ll lose weight. Physical exercise also plays a big role in weight loss, exercise burns calories, so if you keep eating 2000 but exercise and burn off 300 of those, you’ll lose weight gradually.
The problem is that pasta and sauce may not contain all the nutrients you should be eating, especially if there’s no meat or vegetables in the sauce.
In general, I would recommend you limit your pasta intake to one or two meals a day (I recommend one), and have a third meal with veggies, milk, meat, eggs, etc.