This is a very basic question I guess, if I have something like f:A->B, should all the elements in set A be used for f to be a function?
Yes, that is part of the definition of a function. If $f$ is undefined for some elements in the domain but otherwise satisfies the conditions for a function, then it is called a partial function.
A function is a relation between a set of inputs(domain) and a set of permissible outputs(range) with the property that each input is related to exactly one output.
A well-defined function must map every element of its domain to an element of its range.
All of $A$ must be used. But all elements of $B$ need not be mapped to. If all the elements are mapped too, this is known as a surjectivity.
For completeness I will note that having a one to one relationship, that is no element in $A$ maps to two elements of $B$ and no element of $B$ is obtained in mapping from two distinct elements $a_i \;\&\; a_j \in A$, you have injectivity. Together these two properties(and only requiring these two) satisfy a bijection between $A$ and $B$.