A line or 2 of glue on the surface of the carpet pad will often be sufficient.
How to replace a section of carpet padding.
If you are only replacing a 6x9 foot area with no seams i would likely just replace the carpet and pad if i could find a usable pattern on roll at lowes or home depot or a remnant at a dealer.
In either event be prepared to vacuum up a lot of dirt and possible degraded carpet pad.
Tape neighboring pieces together with 2 to 3 inch masking tape or as directed by the manufacturer.
Continue around the other edges of the patch in the same manner except in the case where an edge meets a wall as mentioned above.
Overlap the edges of the new and old padding to cut straight abutting.
Keep in mind that if you plan on replacing the carpet the patch will adhere to the padding making it harder to salvage the pad.
Use a staple hammer tacker to fasten the carpet pad against the edge of the tack strip.
Install new carpet pad.
If carpet tape is not doing the job you can also use carpet glue to hold the patch in position.
Afterward position something heavy over the area to help set the seam.
Press it over the damaged area and turn until you reach the padding then pull out the circular piece and patch as you would a large section.
Place the new pad so the waffled side faces up.
Then use a carpet tractor image 2 to press the carpet down onto the seam tape to reinforce the bond.
Now it is time to install the carpet pad.
Older carpet in high traffic areas might be more faded.