Do I control my Companion and his/her actions or does the DM?

If I control them, does my PC have to be there to give the order? For example, could my PC's wolf stand guard while the party sleeps with me controlling him as a player?