It depends on the situation.
If you're going to be executing several statements in a row, then you're better off performance-wise to open it once, execute all the statements, and then close it,
If you're asking about opening the connection when the program starts and keeping it open until the program closes regardless of what's going on, then no. Close it as soon as you're done with it. It's better not to leave a connection hanging open.
Another factor that people never seem to think of is the maintenance programmer coning along later, who has to trace the code and keep track of where the connection is opened and when it is closes. Say, for example, that you have a program that accesses a database, then branches off into several other functions, each of which may need the connection. Tracking that stuff in code is a nightmare.
Then again, this factor is secondary to proper operation and performance, but still something to consider in a complex app.
The main factor is how it will affect performance vs. the cose of keeping a connection open. You need to decide that in each situation.