You can buy ICOCA card at the ticket counter or the ticket vending machine in the station of JR line. If you need ICOCA card for children, you have to buy it at the ticket counter.
When you buy it, you need to pay 2,000 yen. 500 yen is the returnable deposit, you can use 1500 yen as the fare.
If you want to add money to ICOCA card, you can do it at ticket vending machines of JR line or there are the special machines to add money to it in the stations of JR lines.
If it goes out of use, the returnable deposit is refunded at the ticket counters. But I recommend you to use up all added money, because you have to pay 220 yen as the service charge to receive the refund of the leftover money.