Give the gift card details when you pay and its value comes off what you owe. Anything left stays on the card for next time.

Part-using a card
Spending less than the full value does not lose the remainder. The balance stays on the card until you use it.
If the bill is more than the card
The card covers what it can and you pay the rest as normal.

Mention it before they take payment
Applying a gift card afterwards means refunding and retaking the payment, which is more hassle for everyone. Say at the start that you have one.
Expiry
Terms are set by the business that sold it. Check before you assume, particularly with a card you were given a while ago.
Common questions
Can I use a gift card towards a deposit?
Ask the business. Many will let you.
I have lost the card. Can it be replaced?
Contact the business who sold it. They can see the cards they have issued.
Can I use a gift card at a different business?
No. A gift card is for the business that issued it.